Skip to content

Commit

Permalink
Use embed to format bot reply
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardofano committed Apr 26, 2024
1 parent aefdc50 commit 490a15a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/commands/ask.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {
ApplicationCommandOptionType,
CommandInteraction,
EmbedBuilder,
InteractionResponse,
blockQuote,
bold,
escapeMarkdown,
} from 'discord.js'
import { Discord, Slash, SlashChoice, SlashOption } from 'discordx'
Expand Down Expand Up @@ -54,7 +53,13 @@ class Ask {

try {
const answer = await this.fetchAnswer(question, units)
return interaction.reply(`### ${escapeMarkdown(question)}\n${blockQuote(answer)}`)
const capitalizedAnswer = answer.charAt(0).toUpperCase() + answer.slice(1)
const embed = new EmbedBuilder()
.setColor('#FBAB00') // MasterMind's color
.setTitle(escapeMarkdown(question))
.setDescription(capitalizedAnswer)

return await interaction.reply({ embeds: [embed] })
} catch (err) {
console.error(err)
return interaction.reply({ content: 'There was a problem communicating with Wolfram Alpha.', ephemeral: true })
Expand Down

0 comments on commit 490a15a

Please sign in to comment.