fix removing roles from members (maybe)

This commit is contained in:
ouwou 2022-08-10 23:20:27 -04:00
parent acb80da387
commit 96ec5bb665
2 changed files with 23 additions and 0 deletions

View File

@ -253,6 +253,14 @@ void Store::SetGuildMember(Snowflake guild_id, Snowflake user_id, const GuildMem
s->Reset();
{
auto &s = m_stmt_clr_member_roles;
s->Bind(1, user_id);
s->Bind(2, guild_id);
s->Step();
s->Reset();
}
{
auto &s = m_stmt_set_member_roles;
@ -1881,6 +1889,20 @@ bool Store::CreateStatements() {
return false;
}
m_stmt_clr_member_roles = std::make_unique<Statement>(m_db, R"(
DELETE FROM member_roles
WHERE user = ? AND
EXISTS (
SELECT 1 FROM roles
WHERE member_roles.role = roles.id
AND roles.guild = ?
)
)");
if (!m_stmt_clr_member_roles->OK()) {
fprintf(stderr, "failed to prepare clear member roles statement: %s\n", m_db.ErrStr());
return false;
}
m_stmt_set_guild_emoji = std::make_unique<Statement>(m_db, R"(
REPLACE INTO guild_emojis VALUES (
?, ?

View File

@ -281,6 +281,7 @@ private:
STMT(set_interaction);
STMT(set_member_roles);
STMT(get_member_roles);
STMT(clr_member_roles);
STMT(set_guild_emoji);
STMT(get_guild_emojis);
STMT(clr_guild_emoji);