diff --git a/src/message_queue.cpp b/src/message_queue.cpp index 97ca8d9..ccb3ec5 100644 --- a/src/message_queue.cpp +++ b/src/message_queue.cpp @@ -95,7 +95,7 @@ void bot::message_queue::run(bot::settings::settings *settings, bot::submit_queu std::cerr << "Exception thrown while translating: unknown" << std::endl; } - submit_queue->add(make_translated_message(message, tr_message, dpp::webhook(target->webhook))); + submit_queue->add(make_translated_message(message, tr_message, target->webhook)); } std::this_thread::yield(); diff --git a/src/settings.cpp b/src/settings.cpp index 1e89813..507e8d4 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -26,7 +26,7 @@ uint16_t bot::settings::settings::get_avatar_size() return m_avatarSize; } -const bot::settings::channel *bot::settings::settings::get_channel(bot::settings::guild *guild, uint64_t channel_id) +const bot::settings::channel *bot::settings::settings::get_channel(const bot::settings::guild *guild, dpp::snowflake channel_id) { for (auto channel = guild->channel.begin(); channel != guild->channel.end(); channel++) { if (channel->id == channel_id) @@ -35,7 +35,7 @@ const bot::settings::channel *bot::settings::settings::get_channel(bot::settings return nullptr; } -const bot::settings::channel *bot::settings::settings::get_channel(uint64_t guild_id, uint64_t channel_id) +const bot::settings::channel *bot::settings::settings::get_channel(dpp::snowflake guild_id, dpp::snowflake channel_id) { for (auto guild = m_guilds.begin(); guild != m_guilds.end(); guild++) { if (guild->id == guild_id) { @@ -48,7 +48,7 @@ const bot::settings::channel *bot::settings::settings::get_channel(uint64_t guil return nullptr; } -const bot::settings::guild *bot::settings::settings::get_guild(uint64_t guild_id) +const bot::settings::guild *bot::settings::settings::get_guild(dpp::snowflake guild_id) { for (auto guild = m_guilds.begin(); guild != m_guilds.end(); guild++) { if (guild->id == guild_id) @@ -67,7 +67,7 @@ const std::string bot::settings::settings::get_token() return m_token; } -bool bot::settings::settings::is_translatebot(uint64_t webhook_id) +bool bot::settings::settings::is_translatebot(dpp::snowflake webhook_id) { for (auto id = m_webhookIds.begin(); id != m_webhookIds.end(); id++) { if (*id == webhook_id) @@ -209,21 +209,17 @@ bool bot::settings::settings::parse(const std::string &filename) if (json_channel_target.value().is_string()) { bot::settings::target target; target.target = json_channel_target.value(); - target.webhook = json_channel->at("webhook"); + target.webhook = dpp::webhook(json_channel->at("webhook")); channel.targets.push_back(target); - - const dpp::webhook webhook(target.webhook); - m_webhookIds.push_back(webhook.id); + m_webhookIds.push_back(target.webhook.id); } else if (json_channel_target.value().is_object()) { for (auto json_target = json_channel_target.value().begin(); json_target != json_channel_target.value().end(); json_target++) { bot::settings::target target; target.target = json_target.key(); - target.webhook = json_target.value(); + target.webhook = dpp::webhook(json_target.value()); channel.targets.push_back(target); - - const dpp::webhook webhook(target.webhook); - m_webhookIds.push_back(webhook.id); + m_webhookIds.push_back(target.webhook.id); } } } diff --git a/src/settings.h b/src/settings.h index 0eb5f80..48ae550 100644 --- a/src/settings.h +++ b/src/settings.h @@ -19,6 +19,8 @@ #ifndef SETTINGS_H #define SETTINGS_H #include +#include +#include #include #include #include @@ -27,15 +29,15 @@ namespace bot { namespace settings { struct target { std::string target; - std::string webhook; + dpp::webhook webhook; }; struct channel { - uint64_t id; + dpp::snowflake id; std::string source; std::vector targets; }; struct guild { - uint64_t id; + dpp::snowflake id; std::vector channel; }; struct translate { @@ -49,12 +51,12 @@ namespace bot { class settings { public: uint16_t get_avatar_size(); - const bot::settings::channel* get_channel(bot::settings::guild *guild, uint64_t channel_id); - const bot::settings::channel* get_channel(uint64_t guild_id, uint64_t channel_id); - const bot::settings::guild* get_guild(uint64_t guild_id); + const bot::settings::channel* get_channel(const bot::settings::guild *guild, dpp::snowflake channel_id); + const bot::settings::channel* get_channel(dpp::snowflake guild_id, dpp::snowflake channel_id); + const bot::settings::guild* get_guild(dpp::snowflake guild_id); const bot::settings::translate* get_translate(); const std::string get_token(); - bool is_translatebot(uint64_t webhook_id); + bool is_translatebot(dpp::snowflake webhook_id); void lock(); bool parse(const std::string &filename); void unlock(); @@ -65,7 +67,7 @@ namespace bot { std::vector m_guilds; bot::settings::translate m_translate; std::string m_token; - std::vector m_webhookIds; + std::vector m_webhookIds; }; } }