1
0
Fork 0
mirror of https://gitlab.com/niansa/SomeBot.git synced 2025-03-06 20:48:26 +01:00

Minor fixes and preparation for warnings

This commit is contained in:
niansa 2023-02-19 22:38:44 +01:00
parent e160fdda60
commit fa75f5da6f
3 changed files with 17 additions and 5 deletions

View file

@ -209,10 +209,6 @@ public:
});
bot->cluster.on_message_create([this](const dpp::message_create_t& event) {
// Make sure user isn't a known bot
if (event.msg.author.is_bot()) {
return;
}
// Lock UUID list
std::scoped_lock L(uuid_mutex);
// Get server captcha settings
@ -223,6 +219,10 @@ public:
}
// Delete message later
autodelete_message(event.msg);
// Make sure user isn't a known bot
if (event.msg.author.is_bot()) {
return;
}
// Find user is in UUID list
auto uuid_key = std::to_string(event.msg.guild_id)+std::to_string(event.msg.author.id);
auto res = uuids.find(uuid_key);

View file

@ -35,7 +35,8 @@ public:
return;
}
// Get color
unsigned color = Util::str_to_color(strOrEmpty(event.get_parameter("color")));
auto colorStr = strOrEmpty(event.get_parameter("color"));
unsigned color = Util::str_to_color(colorStr.empty()?"black":colorStr);
// Generate embed
dpp::embed embed;
embed.set_title(strOrEmpty(event.get_parameter("title")))

View file

@ -11,6 +11,10 @@ class Moderation {
bot->db << "INSERT OR IGNORE INTO moderation_guild_settings (id) VALUES (?);"
<< std::to_string(guild_id);
}
void db_add_member(const dpp::snowflake& guild_id, const dpp::snowflake& user_id) {
bot->db << "INSERT OR IGNORE INTO moderation_guild_user_warnings (guild_id, user_id) VALUES (?);"
<< std::to_string(guild_id) << std::to_string(user_id);
}
dpp::snowflake get_moderation_role(const dpp::snowflake& guild_id) {
std::string fres;
bot->db << "SELECT moderation_role FROM moderation_guild_settings "
@ -39,6 +43,13 @@ public:
" logs_channel TEXT,"
" UNIQUE(id)"
");";
bot->db << "CREATE TABLE IF NOT EXISTS moderation_guild_user_warnings ("
" guild_id TEXT NOT NULL,"
" user_id TEXT NOT NULL,"
" amount INTEGER,"
" reasons TEXT,"
" UNIQUE(guild_id, user_id)"
");";
bot->add_chatcommand(Bot::ChatCommand({"purge"}, "Lösche die letzen Nachrichten", dpp::slashcommand().add_option(dpp::command_option(dpp::command_option_type::co_integer, "amount", "Menge", true))), [&](const dpp::slashcommand_t& event) {
unsigned long amount = std::get<long>(event.get_parameter("amount"));