alias all working now
This commit is contained in:
parent
aff303dda6
commit
571802c232
@ -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(_) => {
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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>);
|
||||
|
Loading…
Reference in New Issue
Block a user