Skip to content

Commit 6ae20be

Browse files
committed
Fix export-snippet command
1 parent 44f459b commit 6ae20be

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/commands/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ pub async fn respond_embed(ctx: &Context, interaction: &ApplicationCommandIntera
162162
).await;
163163

164164
if let Err(e) = result {
165-
println!("Failed to respond to interaction: {} {}", interaction.data.name, e)
165+
println!("Failed to respond to interaction '{}': {:#?}", interaction.data.name, e)
166166
}
167167
}
168168

src/commands/snippets.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,20 @@ pub(super) async fn export_snippet(ctx: &Context, interaction: &ApplicationComma
188188

189189
match id {
190190
CommandDataOptionValue::String(id) => {
191+
interaction.defer(ctx).await.expect("Failed to defer interaction");
192+
191193
let snippet = get_snippet(ctx, &id).await
192194
.expect("Failed to get snippet");
193195

194196
let embed = snippet.create_embed();
195197

196198
let result = interaction.create_followup_message(ctx, |r| r
197-
.content(format!("```{}```", snippet.content.replace("\n", r#"\n"#)))
199+
.content(format!("```{}```", &snippet.content.replace("\n", r#"\n"#)))
198200
.add_embed(embed)
199201
).await;
200202

201203
if let Err(e) = result {
202-
println!("Failed to respond to interaction: {} {}", interaction.data.name, e)
204+
println!("Failed to respond to interaction '{}': {:#?}", interaction.data.name, e)
203205
}
204206
},
205207
_ => panic!("Invalid arguments provided to command: {}", interaction.data.name)

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl EventHandler for Handler {
100100

101101
async fn interaction_create(&self, ctx: Context, interaction: Interaction) {
102102
if let Interaction::ApplicationCommand(command) = interaction {
103-
println!("Received command interaction: {}", command.data.name);
103+
println!("Received command interaction '{}'", command.data.name);
104104
commands::interact(&ctx, &command).await;
105105
}
106106
}

0 commit comments

Comments
 (0)