Cache channel in todo list command

Channel was not being cached, placing channel todos into the server todo list.
This commit is contained in:
jude 2022-07-02 08:31:17 +01:00
parent f56db14720
commit f4213c6a83

View File

@ -6,6 +6,7 @@ use crate::{
ComponentDataModel, TodoSelector, ComponentDataModel, TodoSelector,
}, },
consts::{EMBED_DESCRIPTION_MAX_LENGTH, SELECT_MAX_ENTRIES, THEME_COLOR}, consts::{EMBED_DESCRIPTION_MAX_LENGTH, SELECT_MAX_ENTRIES, THEME_COLOR},
models::CtxData,
Context, Error, Context, Error,
}; };
@ -116,6 +117,9 @@ pub async fn todo_channel_add(
ctx: Context<'_>, ctx: Context<'_>,
#[description = "The task to add to the todo list"] task: String, #[description = "The task to add to the todo list"] task: String,
) -> Result<(), Error> { ) -> Result<(), Error> {
// ensure channel is cached
let _ = ctx.channel_data().await;
sqlx::query!( sqlx::query!(
"INSERT INTO todos (guild_id, channel_id, value) "INSERT INTO todos (guild_id, channel_id, value)
VALUES ((SELECT id FROM guilds WHERE guild = ?), (SELECT id FROM channels WHERE channel = ?), ?)", VALUES ((SELECT id FROM guilds WHERE guild = ?), (SELECT id FROM channels WHERE channel = ?), ?)",