1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
import { Message } from "discord.js";
import { sendProgressUpdate, executeBulkRoleAssignment } from "./utilities";
export const handleStartCommand = async (message: Message) => {
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.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(
message.client,
roleId,
updateChannelId,
channelId,
categoryId,
).catch((error) => {
console.error("Bulk role assignment failed:", error);
sendProgressUpdate(
message.client,
"❌ Bulk role assignment failed due to an error",
updateChannelId,
);
});
}
};
|