summaryrefslogtreecommitdiff
path: root/packages/gateway/src/commands/start.ts
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-09-24 19:04:14 -0700
committerFuwn <[email protected]>2025-09-24 19:15:34 -0700
commit3b08854f33c9944761367597e6850fe6e27e3af3 (patch)
tree8b6169d08cc85b0a6a74c761615c2a8e560ac105 /packages/gateway/src/commands/start.ts
parentrefactor: Move interactions client to packages directory (diff)
downloadumabotdiscord-3b08854f33c9944761367597e6850fe6e27e3af3.tar.xz
umabotdiscord-3b08854f33c9944761367597e6850fe6e27e3af3.zip
feat: Integrate gateway client
Diffstat (limited to 'packages/gateway/src/commands/start.ts')
-rw-r--r--packages/gateway/src/commands/start.ts83
1 files changed, 83 insertions, 0 deletions
diff --git a/packages/gateway/src/commands/start.ts b/packages/gateway/src/commands/start.ts
new file mode 100644
index 0000000..4a771ed
--- /dev/null
+++ b/packages/gateway/src/commands/start.ts
@@ -0,0 +1,83 @@
+import { Client, Events, Message } from "discord.js";
+import { sendProgressUpdate, executeBulkRoleAssignment } from "./utilities";
+
+export const handleStartCommand = (client: Client) => {
+ client.on(Events.MessageCreate, async (message: Message) => {
+ if (message.author.bot) return;
+
+ if (message.content.toLowerCase().startsWith("uma!start")) {
+ const application = await client.application?.fetch();
+ const ownerId = application?.owner?.id;
+
+ if (message.author.id !== ownerId) return;
+
+ const parameters = message.content.split(" ").slice(1);
+
+ if (parameters.length < 3) {
+ await message.reply(
+ "❌ Usage: `uma!start <role_mention> <channel_mention_or_category_id> <update_channel_id> [action]`\nExample: `uma!start @Participant #general 1415599617214513254 execute`",
+ );
+
+ return;
+ }
+
+ const roleMention = parameters[0];
+ const channelOrCategory = parameters[1];
+ const updateChannelId = parameters[2];
+ const action = parameters[3] || "execute";
+ const roleMatch = roleMention.match(/<@&(\d+)>/);
+
+ if (!roleMatch) {
+ await message.reply(
+ "❌ Please mention a role. Example: `@Participant`",
+ );
+
+ return;
+ }
+
+ const roleId = roleMatch[1];
+ let channelId: string | undefined;
+ let categoryId: string | undefined;
+ const channelMatch = channelOrCategory.match(/<#(\d+)>/);
+
+ if (channelMatch) {
+ channelId = channelMatch[1];
+ } else {
+ categoryId = channelOrCategory;
+ }
+
+ if (action !== "preview" && action !== "execute") {
+ await message.reply("❌ Action must be either `preview` or `execute`");
+
+ return;
+ }
+
+ if (action === "preview") {
+ await message.reply(
+ "📋 Preview mode - this would check the specified channel(s) for users who have sent messages.",
+ );
+
+ return;
+ }
+
+ await message.reply(
+ "🚀 Bulk role operation started! Check the progress channel for updates.",
+ );
+
+ executeBulkRoleAssignment(
+ client,
+ roleId,
+ updateChannelId,
+ channelId,
+ categoryId,
+ ).catch((error) => {
+ console.error("Bulk role assignment failed:", error);
+ sendProgressUpdate(
+ client,
+ "❌ Bulk role assignment failed due to an error",
+ updateChannelId,
+ );
+ });
+ }
+ });
+};