summaryrefslogtreecommitdiff
path: root/packages/gateway/src/commands/start.ts
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-09-28 00:06:49 -0700
committerFuwn <[email protected]>2025-09-28 00:06:49 -0700
commit956ed319e7722d168b4c23d5c6aeb85b20e5b15d (patch)
treedf2ec3a95d405d0d6c6ebcc93f7de1e2e9f4484d /packages/gateway/src/commands/start.ts
parentrefactor(gateway): Consolidate event handlers (diff)
downloadumabotdiscord-956ed319e7722d168b4c23d5c6aeb85b20e5b15d.tar.xz
umabotdiscord-956ed319e7722d168b4c23d5c6aeb85b20e5b15d.zip
fix(gateway): Lint
Diffstat (limited to 'packages/gateway/src/commands/start.ts')
-rw-r--r--packages/gateway/src/commands/start.ts114
1 files changed, 56 insertions, 58 deletions
diff --git a/packages/gateway/src/commands/start.ts b/packages/gateway/src/commands/start.ts
index b6c9300..9b8beb5 100644
--- a/packages/gateway/src/commands/start.ts
+++ b/packages/gateway/src/commands/start.ts
@@ -2,80 +2,78 @@ import { Message } from "discord.js";
import { sendProgressUpdate, executeBulkRoleAssignment } from "./utilities";
export const handleStartCommand = async (message: Message) => {
- if (message.author.bot) return;
+ if (message.author.bot) return;
- if (message.content.toLowerCase().startsWith("uma!start")) {
- const application = await message.client.application?.fetch();
- const ownerId = application?.owner?.id;
+ if (message.content.toLowerCase().startsWith("uma!start")) {
+ const application = await message.client.application?.fetch();
+ const ownerId = application?.owner?.id;
- if (message.author.id !== ownerId) return;
+ if (message.author.id !== ownerId) return;
- const parameters = message.content.split(" ").slice(1);
+ 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 (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`",
+ );
- if (!roleMatch) {
- await message.reply(
- "❌ Please mention a role. Example: `@Participant`",
- );
+ return;
+ }
- return;
- }
+ const roleMention = parameters[0];
+ const channelOrCategory = parameters[1];
+ const updateChannelId = parameters[2];
+ const action = parameters[3] || "execute";
+ const roleMatch = roleMention.match(/<@&(\d+)>/);
- const roleId = roleMatch[1];
- let channelId: string | undefined;
- let categoryId: string | undefined;
- const channelMatch = channelOrCategory.match(/<#(\d+)>/);
+ if (!roleMatch) {
+ await message.reply("❌ Please mention a role. Example: `@Participant`");
- if (channelMatch) {
- channelId = channelMatch[1];
- } else {
- categoryId = channelOrCategory;
- }
+ return;
+ }
- if (action !== "preview" && action !== "execute") {
- await message.reply("❌ Action must be either `preview` or `execute`");
+ const roleId = roleMatch[1];
+ let channelId: string | undefined;
+ let categoryId: string | undefined;
+ const channelMatch = channelOrCategory.match(/<#(\d+)>/);
- return;
- }
+ if (channelMatch) {
+ channelId = channelMatch[1];
+ } else {
+ categoryId = channelOrCategory;
+ }
- if (action === "preview") {
- await message.reply(
- "📋 Preview mode - this would check the specified channel(s) for users who have sent messages.",
- );
+ if (action !== "preview" && action !== "execute") {
+ await message.reply("❌ Action must be either `preview` or `execute`");
- return;
- }
+ return;
+ }
+ if (action === "preview") {
await message.reply(
- "🚀 Bulk role operation started! Check the progress channel for updates.",
+ "📋 Preview mode - this would check the specified channel(s) for users who have sent messages.",
);
- executeBulkRoleAssignment(
+ return;
+ }
+
+ await message.reply(
+ "🚀 Bulk role operation started! Check the progress channel for updates.",
+ );
+
+ executeBulkRoleAssignment(
+ message.client,
+ roleId,
+ updateChannelId,
+ channelId,
+ categoryId,
+ ).catch((error) => {
+ console.error("Bulk role assignment failed:", error);
+ sendProgressUpdate(
message.client,
- roleId,
+ "❌ Bulk role assignment failed due to an error",
updateChannelId,
- channelId,
- categoryId,
- ).catch((error) => {
- console.error("Bulk role assignment failed:", error);
- sendProgressUpdate(
- message.client,
- "❌ Bulk role assignment failed due to an error",
- updateChannelId,
- );
- });
- }
+ );
+ });
+ }
};