Skip to content

Commit 20c40f3

Browse files
committed
feat(command): add basic command logging
1 parent a261442 commit 20c40f3

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/main.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,25 @@ async fn main() -> anyhow::Result<()> {
3535
let framework = poise::Framework::builder()
3636
.options(poise::FrameworkOptions {
3737
commands: get_commands(),
38+
post_command: |ctx| {
39+
Box::pin(async move {
40+
let author = ctx.author();
41+
let guild = ctx.guild();
42+
let cmd = ctx.command();
43+
44+
let user_info = format!("{}[{}]", author.name, author.id);
45+
46+
let guild_info = if let Some(guild) = guild {
47+
format!("{}[{}]", guild.name, guild.id)
48+
} else {
49+
"Direct Messages".to_string()
50+
};
51+
52+
let command_name = cmd.name.to_lowercase();
53+
54+
info!("{} @ {} {}", user_info, guild_info, command_name);
55+
})
56+
},
3857
..Default::default()
3958
})
4059
.setup(|ctx, _ready, framework| {

0 commit comments

Comments
 (0)