mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-13 20:18:50 +03:00
actually retrieve roles for guilds
FetchRoles isnt needed anymore cuz full roles are fetched now
This commit is contained in:
@@ -765,6 +765,16 @@ std::optional<GuildData> Store::GetGuild(Snowflake id) const {
|
||||
s->Reset();
|
||||
}
|
||||
|
||||
{
|
||||
auto &s = m_stmt_get_guild_roles;
|
||||
s->Bind(1, id);
|
||||
r.Roles.emplace();
|
||||
while (s->FetchOne()) {
|
||||
r.Roles->push_back(GetRoleBound(s));
|
||||
}
|
||||
s->Reset();
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -961,9 +971,17 @@ std::optional<RoleData> Store::GetRole(Snowflake id) const {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto role = GetRoleBound(s);
|
||||
|
||||
s->Reset();
|
||||
|
||||
return role;
|
||||
}
|
||||
|
||||
RoleData Store::GetRoleBound(std::unique_ptr<Statement> &s) const {
|
||||
RoleData r;
|
||||
|
||||
r.ID = id;
|
||||
s->Get(0, r.ID);
|
||||
//s->Get(1, guild id);
|
||||
s->Get(2, r.Name);
|
||||
s->Get(3, r.Color);
|
||||
@@ -973,8 +991,6 @@ std::optional<RoleData> Store::GetRole(Snowflake id) const {
|
||||
s->Get(7, r.IsManaged);
|
||||
s->Get(8, r.IsMentionable);
|
||||
|
||||
s->Reset();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -1726,6 +1742,14 @@ bool Store::CreateStatements() {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_stmt_get_guild_roles = std::make_unique<Statement>(m_db, R"(
|
||||
SELECT * FROM roles WHERE guild = ?
|
||||
)");
|
||||
if (!m_stmt_get_guild_roles->OK()) {
|
||||
fprintf(stderr, "failed to prepare get guild roles statement: %s\n", m_db.ErrStr());
|
||||
return false;
|
||||
}
|
||||
|
||||
m_stmt_set_emoji = std::make_unique<Statement>(m_db, R"(
|
||||
REPLACE INTO emojis VALUES (
|
||||
?, ?, ?, ?, ?, ?, ?
|
||||
|
||||
Reference in New Issue
Block a user