From f4213c6a831fe0fe960a2d14ba654b4cc2406cd8 Mon Sep 17 00:00:00 2001 From: jude Date: Sat, 2 Jul 2022 08:31:17 +0100 Subject: [PATCH] Cache channel in todo list command Channel was not being cached, placing channel todos into the server todo list. --- src/commands/todo_cmds.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/commands/todo_cmds.rs b/src/commands/todo_cmds.rs index 742813d..90be423 100644 --- a/src/commands/todo_cmds.rs +++ b/src/commands/todo_cmds.rs @@ -6,6 +6,7 @@ use crate::{ ComponentDataModel, TodoSelector, }, consts::{EMBED_DESCRIPTION_MAX_LENGTH, SELECT_MAX_ENTRIES, THEME_COLOR}, + models::CtxData, Context, Error, }; @@ -116,6 +117,9 @@ pub async fn todo_channel_add( ctx: Context<'_>, #[description = "The task to add to the todo list"] task: String, ) -> Result<(), Error> { + // ensure channel is cached + let _ = ctx.channel_data().await; + sqlx::query!( "INSERT INTO todos (guild_id, channel_id, value) VALUES ((SELECT id FROM guilds WHERE guild = ?), (SELECT id FROM channels WHERE channel = ?), ?)",