alias all working now
This commit is contained in:
parent
aff303dda6
commit
571802c232
@ -22,7 +22,9 @@ use crate::{
|
|||||||
GuildData,
|
GuildData,
|
||||||
},
|
},
|
||||||
SQLPool,
|
SQLPool,
|
||||||
|
FrameworkCtx,
|
||||||
};
|
};
|
||||||
|
use serenity::framework::Framework;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref REGEX_CHANNEL: Regex = Regex::new(r#"^\s*<#(\d+)>\s*$"#).unwrap();
|
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 {
|
else {
|
||||||
match sqlx::query!(
|
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)
|
", guild_id, name)
|
||||||
.fetch_one(&pool)
|
.fetch_one(&pool)
|
||||||
.await {
|
.await {
|
||||||
|
|
||||||
Ok(row) => {
|
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(_) => {
|
Err(_) => {
|
||||||
|
@ -295,8 +295,7 @@ impl Framework for RegexFramework {
|
|||||||
if (msg.author.bot && self.ignore_bots) ||
|
if (msg.author.bot && self.ignore_bots) ||
|
||||||
msg.tts ||
|
msg.tts ||
|
||||||
msg.content.len() == 0 ||
|
msg.content.len() == 0 ||
|
||||||
msg.attachments.len() > 0
|
msg.attachments.len() > 0 {
|
||||||
{
|
|
||||||
return
|
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("offset", &reminder_cmds::OFFSET_COMMAND)
|
||||||
.add_command("nudge", &reminder_cmds::NUDGE_COMMAND)
|
.add_command("nudge", &reminder_cmds::NUDGE_COMMAND)
|
||||||
|
|
||||||
|
.add_command("alias", &moderation_cmds::ALIAS_COMMAND)
|
||||||
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let framework_arc = Arc::new(Box::new(framework) as Box<dyn Framework + Send + Sync>);
|
let framework_arc = Arc::new(Box::new(framework) as Box<dyn Framework + Send + Sync>);
|
||||||
|
Loading…
Reference in New Issue
Block a user