-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a8c2a3
commit 4b47efd
Showing
1 changed file
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,49 @@ | ||
import { SlashCommandBuilder, type ChatInputCommandInteraction } from "discord.js"; | ||
import { SlashCommandBuilder, type ChatInputCommandInteraction, type TextChannel } from "discord.js"; | ||
import { type Command } from "../../types/Command"; | ||
import type CrystalClient from "../../types/CrystalClient"; | ||
|
||
module.exports = { | ||
name: 'react', | ||
data: new SlashCommandBuilder() | ||
.setName("react") | ||
.setDescription("React to a message using the bot."), | ||
.setDescription("React to a message using the bot.") | ||
.addChannelOption((option) => | ||
option | ||
.setName('channel') | ||
.setDescription('The channel you want to react to.') | ||
.setRequired(true)) | ||
.addStringOption((option) => | ||
option | ||
.setName('message_id') | ||
.setDescription('The message you want to react to using a message id.') | ||
.setRequired(true)) | ||
.addStringOption((option) => | ||
option | ||
.setName('emoji') | ||
.setDescription('The emoji you want to react with.') | ||
.setRequired(true)), | ||
execute: async function (interaction: ChatInputCommandInteraction, client: CrystalClient) { | ||
|
||
const textChannel = interaction.options.getChannel('channel') as TextChannel | ||
const messageId = interaction.options.getString('message_id') | ||
const reactEmoji = interaction.options.getString('emoji') | ||
|
||
try { | ||
if ((reactEmoji !== null) && (messageId !== null)) { | ||
const targetMessage = await textChannel.messages.fetch(messageId); | ||
|
||
void await targetMessage.react(reactEmoji) | ||
void await interaction.reply({ | ||
content: "The reaction was successful.", | ||
ephemeral: true | ||
}) | ||
} else { | ||
void await interaction.reply({ | ||
content: "The reaction failed.", | ||
ephemeral: true | ||
}) | ||
} | ||
} catch (error) { | ||
console.error() | ||
} | ||
} | ||
} satisfies Command |