summaryrefslogtreecommitdiff
path: root/packages/gateway/src/commands/sayc.ts
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-10-16 00:02:40 -0700
committerFuwn <[email protected]>2025-10-16 00:02:40 -0700
commit357657bfe89e098a6c614a53e576c0414f82d6d1 (patch)
treee659478455be0ebb4a9003dd480f9ca3d39d4cd3 /packages/gateway/src/commands/sayc.ts
parentfeat(gateway:messageCreate): Refine welcome constants (diff)
downloadumabotdiscord-357657bfe89e098a6c614a53e576c0414f82d6d1.tar.xz
umabotdiscord-357657bfe89e098a6c614a53e576c0414f82d6d1.zip
feat(gateway:commands): Add sayc command
Diffstat (limited to 'packages/gateway/src/commands/sayc.ts')
-rw-r--r--packages/gateway/src/commands/sayc.ts52
1 files changed, 52 insertions, 0 deletions
diff --git a/packages/gateway/src/commands/sayc.ts b/packages/gateway/src/commands/sayc.ts
new file mode 100644
index 0000000..eafb2f1
--- /dev/null
+++ b/packages/gateway/src/commands/sayc.ts
@@ -0,0 +1,52 @@
+import { Message } from "discord.js";
+import { replyWithCleanup } from "../utilities";
+
+export const handleSaycCommand = async (message: Message): Promise<boolean> => {
+ if (message.author.bot) return false;
+
+ const content = message.content.trim();
+ const commandMatch = content.match(/^uma!sayc\s+(\d+)\s+(.+)$/s);
+
+ if (!commandMatch) return false;
+
+ const [, channelId, messageContent] = commandMatch;
+
+ if (!messageContent.trim()) {
+ await replyWithCleanup(
+ message,
+ "❌ You need to provide a message to send.",
+ );
+
+ return true;
+ }
+
+ try {
+ const targetChannel = message.client.channels.cache.get(channelId);
+
+ if (
+ !targetChannel ||
+ !targetChannel.isTextBased() ||
+ targetChannel.isDMBased()
+ ) {
+ await replyWithCleanup(
+ message,
+ "❌ Channel not found or is not a text channel.",
+ );
+
+ return true;
+ }
+
+ await targetChannel.send(messageContent);
+ await replyWithCleanup(message, `✅ Message sent to <#${channelId}>.`);
+
+ return true;
+ } catch (error) {
+ console.error("Error in sayc command:", error);
+ await replyWithCleanup(
+ message,
+ "❌ Failed to send message to the specified channel.",
+ );
+
+ return true;
+ }
+};