Add unrecognised command message, closes #1
This commit is contained in:
parent
531cfedc17
commit
9295fb48f8
2 changed files with 12 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
use serenity::framework::standard::{macros::command, CommandResult};
|
use serenity::framework::standard::{macros::command, CommandResult};
|
||||||
use serenity::model::prelude::*;
|
use serenity::model::prelude::*;
|
||||||
use serenity::prelude::*;
|
use serenity::prelude::*;
|
||||||
|
use serenity::framework::standard::macros::hook;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
|
@ -31,3 +32,12 @@ __**Kanji 漢字**__
|
||||||
msg.reply(&ctx.http, message).await?;
|
msg.reply(&ctx.http, message).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[hook]
|
||||||
|
pub async fn unrecognised_command_hook(
|
||||||
|
ctx: &Context,
|
||||||
|
msg: &Message,
|
||||||
|
unrecognised_command_name: &str,
|
||||||
|
) {
|
||||||
|
msg.reply(&ctx.http, &format!("I don't understand the command '{}'. For a list of commands, see `{}help`. Commands are case-sensitive.", unrecognised_command_name, env::var("PREFIX").unwrap())).await.unwrap();
|
||||||
|
}
|
|
@ -97,7 +97,8 @@ async fn main() {
|
||||||
// Create the framework
|
// Create the framework
|
||||||
let framework = StandardFramework::new()
|
let framework = StandardFramework::new()
|
||||||
.configure(|c| c.owners(owners).prefix(prefix))
|
.configure(|c| c.owners(owners).prefix(prefix))
|
||||||
.group(&GENERAL_GROUP);
|
.group(&GENERAL_GROUP)
|
||||||
|
.unrecognised_command(commands::meta::unrecognised_command_hook);
|
||||||
|
|
||||||
let mut client = Client::builder(&token)
|
let mut client = Client::builder(&token)
|
||||||
.framework(framework)
|
.framework(framework)
|
||||||
|
|
Loading…
Add table
Reference in a new issue