diff --git a/include/discord.h b/include/discord.h index 18b8781..86e008e 100644 --- a/include/discord.h +++ b/include/discord.h @@ -48,7 +48,12 @@ public slots: * @param reason The reason the client specified for the modcall. * @param current_area The index of the area the modcall is made. */ - void postModcallWebhook(QString name, QString area, QString reason, int current_area); + void postModcallWebhook(QString name, QString reason, int current_area); + + /** + * @brief Sends the reply to the POST request sent by Discord::postModcallWebhook. + */ + void onFinish(QNetworkReply *reply); private: @@ -57,13 +62,6 @@ private: */ Server* server; -private slots: - - /** - * @brief Sends the reply to the POST request sent by Discord::postModcallWebhook. - */ - void onFinish(QNetworkReply *reply); - }; #endif // DISCORD_H diff --git a/include/server.h b/include/server.h index e53ec81..fe10e6a 100644 --- a/include/server.h +++ b/include/server.h @@ -245,12 +245,12 @@ class Server : public QObject { bool webhook_enabled; /** - * @brief The URL of the discord webhook. + * @brief Requires an https Webhook link, including both ID and Token in the link. */ QString webhook_url; /** - * @brief If the modcall buffer is send as a file. + * @brief If the modcall buffer is sent as a file. */ bool webhook_sendfile; @@ -331,11 +331,10 @@ class Server : public QObject { * @brief Sends a modcall webhook request, emitted by AOClient::pktModcall. * * @param name The character or OOC name of the client who sent the modcall. - * @param area_name The name of the area the modcall was sent from. * @param reason The reason the client specified for the modcall. - * @param + * @param current_area Integer ID of the area the modcall is made. */ - void webhookRequest(QString name, QString area_name, QString reason, int current_area); + void webhookRequest(QString name, QString reason, int current_area); private: /** diff --git a/src/discord.cpp b/src/discord.cpp index 40d888a..5c2485a 100644 --- a/src/discord.cpp +++ b/src/discord.cpp @@ -17,7 +17,7 @@ ////////////////////////////////////////////////////////////////////////////////////// #include "include/discord.h" -void Discord::postModcallWebhook(QString name, QString area, QString reason, int current_area) +void Discord::postModcallWebhook(QString name, QString reason, int current_area) { if (!QUrl (server->webhook_url).isValid()) { qWarning() << "Invalid webhook url!"; @@ -37,7 +37,7 @@ void Discord::postModcallWebhook(QString name, QString area, QString reason, int QJsonArray jsonArray; QJsonObject jsonObject { {"color", "13312842"}, - {"title", name + " filed a modcall in " + area}, + {"title", name + " filed a modcall in " + server->areas[current_area]->name}, {"description", reason} }; jsonArray.append(jsonObject); diff --git a/src/packets.cpp b/src/packets.cpp index 42733db..c5633dc 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -333,7 +333,7 @@ void AOClient::pktModCall(AreaData* area, int argc, QStringList argv, AOPacket p if (ooc_name.isEmpty()) name = current_char; - server->webhookRequest(name, area->name, packet.contents[0], current_area); + server->webhookRequest(name, packet.contents[0], current_area); } area->logger->flush(); } diff --git a/src/server.cpp b/src/server.cpp index 6b45068..948c41a 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -307,6 +307,7 @@ void Server::loadServerConfig() webhook_enabled = config.value("webhook_enabled", "false").toBool(); webhook_url = config.value("webhook_url", "Your webhook url here.").toString(); webhook_sendfile = config.value("webhook_sendfile", false).toBool(); + config.endGroup(); } Server::~Server()