removed some duped code

This commit is contained in:
2020-12-18 11:46:22 +00:00
parent fd4acc4b9d
commit 26825ff4e5
5 changed files with 65 additions and 283 deletions

View File

@ -13,6 +13,7 @@ use std::fmt;
use crate::{
consts::THEME_COLOR,
get_ctx_data,
models::{GuildData, UserData},
SQLPool,
};
@ -237,19 +238,7 @@ DELETE FROM todos WHERE user_id = (SELECT id FROM users WHERE user = ?) AND guil
}
async fn execute(&self, ctx: &Context, msg: &Message, subcommand: SubCommand, extra: String) {
let pool;
let lm;
{
let data = ctx.data.read().await;
pool = data
.get::<SQLPool>()
.cloned()
.expect("Could not get SQLPool from data");
lm = data.get::<LanguageManager>().cloned().unwrap();
}
let (pool, lm) = get_ctx_data(&ctx).await;
let user_data = UserData::from_user(&msg.author, &ctx, &pool).await.unwrap();
let prefix = GuildData::prefix_from_id(msg.guild_id, &pool).await;
@ -442,19 +431,7 @@ async fn todo_guild(ctx: &Context, msg: &Message, args: String) {
}
async fn show_help(ctx: &Context, msg: &Message, target: Option<TodoTarget>) {
let pool;
let lm;
{
let data = ctx.data.read().await;
pool = data
.get::<SQLPool>()
.cloned()
.expect("Could not get SQLPool from data");
lm = data.get::<LanguageManager>().cloned().unwrap();
}
let (pool, lm) = get_ctx_data(&ctx).await;
let user_data = UserData::from_user(&msg.author, &ctx, &pool).await.unwrap();
let prefix = GuildData::prefix_from_id(msg.guild_id, &pool).await;