diff options
| author | Fuwn <[email protected]> | 2025-09-27 16:17:37 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-09-27 16:17:37 -0700 |
| commit | 17b7e24c59f4404305f30142f871764966230cab (patch) | |
| tree | 9d2be6c84954a463f44232456282a3661813d879 /packages | |
| parent | fix: Clean up non-essential debug logs (diff) | |
| download | umabotdiscord-17b7e24c59f4404305f30142f871764966230cab.tar.xz umabotdiscord-17b7e24c59f4404305f30142f871764966230cab.zip | |
feat(gateway:commands): Add react command
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/gateway/src/commands/index.ts | 2 | ||||
| -rw-r--r-- | packages/gateway/src/commands/react.ts | 39 |
2 files changed, 41 insertions, 0 deletions
diff --git a/packages/gateway/src/commands/index.ts b/packages/gateway/src/commands/index.ts index 29e3f71..b3dd2a2 100644 --- a/packages/gateway/src/commands/index.ts +++ b/packages/gateway/src/commands/index.ts @@ -2,9 +2,11 @@ import { Client } from "discord.js"; import { handleSayCommand } from "./say"; import { handleStartCommand } from "./start"; import { handleCrpCommand } from "./crp"; +import { handleReactCommand } from "./react"; export const handleCommands = (client: Client) => { handleSayCommand(client); handleStartCommand(client); handleCrpCommand(client); + handleReactCommand(client); }; diff --git a/packages/gateway/src/commands/react.ts b/packages/gateway/src/commands/react.ts new file mode 100644 index 0000000..ef18d8f --- /dev/null +++ b/packages/gateway/src/commands/react.ts @@ -0,0 +1,39 @@ +import { Client, Events, Message } from "discord.js"; + +export const handleReactCommand = (client: Client) => { + client.on(Events.MessageCreate, async (message: Message) => { + if (message.author.bot) return; + + if (!message.content.startsWith("uma!react")) return; + + if (!message.guild || message.author.id !== message.guild.ownerId) + return; + + const parameters = message.content.split(" "); + + if (parameters.length < 3) { + await message.reply("Usage: `uma!react <message_id> <emoji>`"); + + return; + } + + const messageId = parameters[1]; + const emoji = parameters[2]; + + try { + const targetMessage = await message.channel.messages.fetch(messageId); + + if (!targetMessage) { + await message.reply("Message not found."); + + return; + } + + await targetMessage.react(emoji); + } catch (error) { + console.error("Error reacting to message:", error); + + await message.reply("Failed to react to the message."); + } + }); +}; |