From 9295fb48f8cb55f7715706302012e97b53373797 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Sat, 26 Feb 2022 18:20:12 -0800 Subject: [PATCH] Add unrecognised command message, closes #1 --- src/commands/meta.rs | 10 ++++++++++ src/main.rs | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/commands/meta.rs b/src/commands/meta.rs index a32fc8f..0bfc22b 100644 --- a/src/commands/meta.rs +++ b/src/commands/meta.rs @@ -1,6 +1,7 @@ use serenity::framework::standard::{macros::command, CommandResult}; use serenity::model::prelude::*; use serenity::prelude::*; +use serenity::framework::standard::macros::hook; use std::env; @@ -31,3 +32,12 @@ __**Kanji 漢字**__ msg.reply(&ctx.http, message).await?; 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(); +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 55e411e..ae713d8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -97,7 +97,8 @@ async fn main() { // Create the framework let framework = StandardFramework::new() .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) .framework(framework)