-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdfunk-toggle.handler.ts
More file actions
28 lines (27 loc) · 1.06 KB
/
dfunk-toggle.handler.ts
File metadata and controls
28 lines (27 loc) · 1.06 KB
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
import { GuildChatInputCommandInteraction } from "../../../../shared/types/GuildChatInputCommandType";
import { jobs } from "../../../../index";
import { MessageFlags } from "discord.js";
export const handleDfunkToggle = async (
interaction: GuildChatInputCommandInteraction
): Promise<void> => {
// We assume that this job is loaded
const dfunkUpdateJob = jobs.get("updateDfunkRoles")!;
const jobStatus = dfunkUpdateJob.job.isActive;
if (jobStatus) {
await dfunkUpdateJob.job.stop();
await interaction.reply({
content: `
The automatic dfunk role update has been turned off.
Use this same command (\`/dfunk toggle\`) to turn on this functionality.`,
flags: MessageFlags.Ephemeral,
});
} else {
await dfunkUpdateJob.job.start();
await interaction.reply({
content: `The automatic dfunk role update has been turned on.
The next automatic update will be executed ${dfunkUpdateJob.job.nextDate()}.
Use this same command (\`/dfunk toggle\`) to turn off this functionality.`,
flags: MessageFlags.Ephemeral,
});
}
};