summaryrefslogtreecommitdiff
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
parentfeat(gateway:messageCreate): Refine welcome constants (diff)
downloadumabotdiscord-357657bfe89e098a6c614a53e576c0414f82d6d1.tar.xz
umabotdiscord-357657bfe89e098a6c614a53e576c0414f82d6d1.zip
feat(gateway:commands): Add sayc command
-rw-r--r--packages/gateway/src/commands/commandHandler.ts3
-rw-r--r--packages/gateway/src/commands/say.ts2
-rw-r--r--packages/gateway/src/commands/sayc.ts52
3 files changed, 57 insertions, 0 deletions
diff --git a/packages/gateway/src/commands/commandHandler.ts b/packages/gateway/src/commands/commandHandler.ts
index b1247c1..5b99c16 100644
--- a/packages/gateway/src/commands/commandHandler.ts
+++ b/packages/gateway/src/commands/commandHandler.ts
@@ -1,5 +1,6 @@
import { Client, Events, Message } from "discord.js";
import { handleSayCommand } from "./say";
+import { handleSaycCommand } from "./sayc";
import { handleStartCommand } from "./start";
import { handleCrpCommand } from "./crp";
import { handleReactCommand } from "./react";
@@ -13,8 +14,10 @@ export const handleCommandHandler = (client: Client) => {
if (message.author.bot) return;
const verbalGatesHandled = await handleVerbalGatesCommand(message);
+ const saycHandled = await handleSaycCommand(message);
(message as any).verbalGatesHandled = verbalGatesHandled;
+ (message as any).saycHandled = saycHandled;
await Promise.allSettled([
handleSayCommand(message),
diff --git a/packages/gateway/src/commands/say.ts b/packages/gateway/src/commands/say.ts
index 76a6ec3..2783fb0 100644
--- a/packages/gateway/src/commands/say.ts
+++ b/packages/gateway/src/commands/say.ts
@@ -4,6 +4,8 @@ import { replyWithCleanup } from "../utilities";
export const handleSayCommand = async (message: Message) => {
if (message.author.bot) return;
+ if ((message as any).saycHandled) return;
+
if (message.content.toLowerCase().startsWith("uma!say")) {
const application = await message.client.application?.fetch();
const ownerId = application?.owner?.id;
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;
+ }
+};