Fix: add generated webhooks to webhook vector

This commit is contained in:
Syping 2024-01-25 21:25:33 +01:00
parent 3a158b400f
commit eb301aee1c
3 changed files with 12 additions and 3 deletions

View file

@ -142,8 +142,10 @@ int main(int argc, char* argv[]) {
s_target.webhook = webhook; s_target.webhook = webhook;
s_channel.targets.push_back(s_target); s_channel.targets.push_back(s_target);
const std::lock_guard<bot::settings::settings> guard(settings); settings.lock();
settings.add_channel(s_channel, event.command.guild_id); settings.add_channel(s_channel, event.command.guild_id);
settings.add_translatebot_webhook(webhook);
settings.unlock();
event.reply(dpp::message("Channel will be now translated!").set_flags(dpp::m_ephemeral)); event.reply(dpp::message("Channel will be now translated!").set_flags(dpp::m_ephemeral));
}); });
@ -158,8 +160,10 @@ int main(int argc, char* argv[]) {
s_target.webhook = *webhook; s_target.webhook = *webhook;
s_channel.targets.push_back(s_target); s_channel.targets.push_back(s_target);
const std::lock_guard<bot::settings::settings> guard(settings); settings.lock();
settings.add_channel(s_channel, event.command.guild_id); settings.add_channel(s_channel, event.command.guild_id);
settings.add_translatebot_webhook(*webhook);
settings.unlock();
event.reply(dpp::message("Channel will be now translated!").set_flags(dpp::m_ephemeral)); event.reply(dpp::message("Channel will be now translated!").set_flags(dpp::m_ephemeral));
} }

View file

@ -36,7 +36,11 @@ void bot::settings::settings::add_channel(const bot::settings::channel &channel,
guild.id = guild_id; guild.id = guild_id;
guild.channel.push_back(channel); guild.channel.push_back(channel);
m_guilds.push_back(guild); m_guilds.push_back(guild);
return; }
void bot::settings::settings::add_translatebot_webhook(const dpp::webhook &webhook)
{
m_webhookIds.push_back(webhook.id);
} }
uint16_t bot::settings::settings::get_avatar_size() uint16_t bot::settings::settings::get_avatar_size()

View file

@ -52,6 +52,7 @@ namespace bot {
class settings { class settings {
public: public:
void add_channel(const bot::settings::channel &channel, dpp::snowflake guild_id); void add_channel(const bot::settings::channel &channel, dpp::snowflake guild_id);
void add_translatebot_webhook(const dpp::webhook &webhook);
uint16_t get_avatar_size(); uint16_t get_avatar_size();
const bot::settings::channel* get_channel(const bot::settings::guild *guild, dpp::snowflake channel_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::channel* get_channel(dpp::snowflake guild_id, dpp::snowflake channel_id);