mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-30 15:17:43 -05:00
Add SRO coach command
This commit is contained in:
49
discord-bot/commands/coach.ts
Normal file
49
discord-bot/commands/coach.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||
import type { GuildMemberRoleManager } from "discord.js";
|
||||
import ids from "../ids";
|
||||
import type { BotCommand } from "../types";
|
||||
|
||||
const COMMAND_NAME = "coach";
|
||||
const ACTION_ARG = "action";
|
||||
|
||||
export const coachRoleCommand: BotCommand = {
|
||||
guilds: [ids.guilds.sro],
|
||||
name: COMMAND_NAME,
|
||||
builder: new SlashCommandBuilder()
|
||||
.setName(COMMAND_NAME)
|
||||
.setDescription(
|
||||
"Turn on/off role indicating you are available to coach other players"
|
||||
)
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName(ACTION_ARG)
|
||||
.setDescription("Add or remove the role?")
|
||||
.setRequired(true)
|
||||
.addChoices(
|
||||
{
|
||||
name: "add",
|
||||
value: "add",
|
||||
},
|
||||
{
|
||||
name: "remove",
|
||||
value: "remove",
|
||||
}
|
||||
)
|
||||
),
|
||||
execute: async ({ interaction }) => {
|
||||
const roleBeingAdded = interaction.options.getString(ACTION_ARG) === "add";
|
||||
const commandUserRoles = interaction.member
|
||||
?.roles as GuildMemberRoleManager;
|
||||
|
||||
if (roleBeingAdded) {
|
||||
await commandUserRoles.add(ids.roles.sroCoach);
|
||||
} else {
|
||||
await commandUserRoles.remove(ids.roles.sroCoach);
|
||||
}
|
||||
|
||||
return interaction.reply({
|
||||
content: roleBeingAdded ? "Role added" : "Role removed",
|
||||
ephemeral: true,
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -5,6 +5,7 @@ import { plusCommand } from "./plus";
|
||||
import { updateAllCommand } from "./updateall";
|
||||
import { pingRolesCommand } from "./pings";
|
||||
import { colorCommand } from "./color";
|
||||
import { coachRoleCommand } from "./coach";
|
||||
import type { BotCommand } from "../types";
|
||||
|
||||
export const commands = [
|
||||
@@ -15,6 +16,7 @@ export const commands = [
|
||||
updateAllCommand,
|
||||
pingRolesCommand,
|
||||
colorCommand,
|
||||
coachRoleCommand,
|
||||
];
|
||||
|
||||
export const commandsMap = Object.fromEntries(commands.map((c) => [c.name, c]));
|
||||
|
||||
@@ -4,6 +4,7 @@ const ids = {
|
||||
},
|
||||
roles: {
|
||||
sroLfg: "749589703371653158",
|
||||
sroCoach: "1053243405179826266",
|
||||
plusTwoPings: "678602424314888224",
|
||||
plusThreePings: "818060819811663872",
|
||||
plusOne: "657613334249734165",
|
||||
|
||||
Reference in New Issue
Block a user