summaryrefslogtreecommitdiff
path: root/packages/gateway/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/gateway/src')
-rw-r--r--packages/gateway/src/commands/index.ts2
-rw-r--r--packages/gateway/src/commands/react.ts39
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.");
+ }
+ });
+};