summaryrefslogtreecommitdiff
path: root/src/discord/store.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/discord/store.cpp')
-rw-r--r--src/discord/store.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/discord/store.cpp b/src/discord/store.cpp
index 5e4e3b3..e182c70 100644
--- a/src/discord/store.cpp
+++ b/src/discord/store.cpp
@@ -571,6 +571,23 @@ std::vector<ChannelData> Store::GetActiveThreads(Snowflake channel_id) const {
return ret;
}
+std::vector<Snowflake> Store::GetChannelIDsWithParentID(Snowflake channel_id) const {
+ auto &s = m_stmt_get_chan_ids_parent;
+
+ s->Bind(1, channel_id);
+
+ std::vector<Snowflake> ret;
+ while (s->FetchOne()) {
+ Snowflake x;
+ s->Get(0, x);
+ ret.push_back(x);
+ }
+
+ s->Reset();
+
+ return ret;
+}
+
void Store::AddReaction(const MessageReactionAddObject &data, bool byself) {
auto &s = m_stmt_add_reaction;
@@ -2120,6 +2137,14 @@ bool Store::CreateStatements() {
return false;
}
+ m_stmt_get_chan_ids_parent = std::make_unique<Statement>(m_db, R"(
+ SELECT id FROM channels WHERE parent_id = ?
+ )");
+ if (!m_stmt_get_chan_ids_parent->OK()) {
+ fprintf(stderr, "failed to prepare get channel ids for parent statement: %s\n", m_db.ErrStr());
+ return false;
+ }
+
return true;
}