Skip to content

Commit

Permalink
fix: Bot nie odświeża szczęśliwego numerka #2
Browse files Browse the repository at this point in the history
  • Loading branch information
konhi committed Oct 29, 2021
1 parent 70cca52 commit b896029
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions src/core/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,29 @@ const slashCommands: Discord.ChatInputApplicationCommandData[] = [
}
]

const replies: {[commandName: string]: Discord.InteractionReplyOptions} = {
github: {
content: 'https://github.com/ElektronPlus/discord',
ephemeral: true
},
numerek: {
content: await getLuckyNumberInfo(),
ephemeral: true
},
aplikacja: {
content: 'https://play.google.com/store/apps/details?id=pl.krystian_wybranowski.elektronPlus',
ephemeral: true
},
spolecznosciowy: {
content: 'https://discord.gg/jrDxSTE',
ephemeral: true
},
facebook: {
content: 'https://www.facebook.com/zgelektronik/ & https://www.facebook.com/suelektron/',
ephemeral: true
/** Use function instead of object to allow dynamic content, like lucky number */
async function getReplies (): Promise<{ [commandName: string]: Discord.InteractionReplyOptions} > {
return {
github: {
content: 'https://github.com/ElektronPlus/discord',
ephemeral: true
},
numerek: {
content: await getLuckyNumberInfo(),
ephemeral: true
},
aplikacja: {
content: 'https://play.google.com/store/apps/details?id=pl.krystian_wybranowski.elektronPlus',
ephemeral: true
},
spolecznosciowy: {
content: 'https://discord.gg/jrDxSTE',
ephemeral: true
},
facebook: {
content: 'https://www.facebook.com/zgelektronik/ & https://www.facebook.com/suelektron/',
ephemeral: true
}
}
}

Expand All @@ -74,6 +77,8 @@ export async function replyToSlashCommand (interaction: Discord.Interaction): Pr
}

for (const command of slashCommands) {
const replies = await getReplies()

if (interaction.commandName === command.name) {
interaction.reply(replies[command.name])
log.info(`[${interaction.guild?.name}] Replied to interaction (${interaction.commandName}).`)
Expand Down

0 comments on commit b896029

Please sign in to comment.