alias all working now

This commit is contained in:
jude 2020-09-04 21:21:47 +01:00
parent aff303dda6
commit 571802c232
3 changed files with 13 additions and 4 deletions

View File

@ -22,7 +22,9 @@ use crate::{
GuildData,
},
SQLPool,
FrameworkCtx,
};
use serenity::framework::Framework;
lazy_static! {
static ref REGEX_CHANNEL: Regex = Regex::new(r#"^\s*<#(\d+)>\s*$"#).unwrap();
@ -309,13 +311,19 @@ UPDATE command_aliases SET command = ? WHERE guild_id = (SELECT id FROM guilds W
else {
match sqlx::query!(
"
SELECT command FROM command_aliases WHERE guild_id = ? AND name = ?
SELECT command FROM command_aliases WHERE guild_id = (SELECT id FROM guilds WHERE guild = ?) AND name = ?
", guild_id, name)
.fetch_one(&pool)
.await {
Ok(row) => {
// run aliased command content
let framework = ctx.data.read().await
.get::<FrameworkCtx>().cloned().expect("Could not get FrameworkCtx from data");
let mut new_msg = msg.clone();
new_msg.content = format!("<@{}> {}", &ctx.cache.current_user_id().await, row.command);
framework.dispatch(ctx.clone(), new_msg).await;
},
Err(_) => {

View File

@ -295,8 +295,7 @@ impl Framework for RegexFramework {
if (msg.author.bot && self.ignore_bots) ||
msg.tts ||
msg.content.len() == 0 ||
msg.attachments.len() > 0
{
msg.attachments.len() > 0 {
return
}

View File

@ -86,6 +86,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
.add_command("offset", &reminder_cmds::OFFSET_COMMAND)
.add_command("nudge", &reminder_cmds::NUDGE_COMMAND)
.add_command("alias", &moderation_cmds::ALIAS_COMMAND)
.build();
let framework_arc = Arc::new(Box::new(framework) as Box<dyn Framework + Send + Sync>);