feat: class role commands
This commit is contained in:
parent
131478222f
commit
d266ac622c
50
index.js
50
index.js
@ -10,7 +10,11 @@ const {
|
||||
} = require("./config.json");
|
||||
|
||||
const client = new Client({
|
||||
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates],
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
GatewayIntentBits.GuildMembers,
|
||||
GatewayIntentBits.GuildVoiceStates
|
||||
],
|
||||
});
|
||||
|
||||
client.on("ready", () => {
|
||||
@ -21,6 +25,48 @@ client.on("interactionCreate", async (interaction) => {
|
||||
const command = interaction.commandName;
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
if (
|
||||
command === "scout" ||
|
||||
command === "soldier" ||
|
||||
command === "pyro" ||
|
||||
command === "demoman" ||
|
||||
command === "demo" ||
|
||||
command === "heavy" ||
|
||||
command === "engineer" ||
|
||||
command === "engi" ||
|
||||
command === "medic" ||
|
||||
command === "sniper" ||
|
||||
command === "spy"
|
||||
) {
|
||||
await interaction.deferReply();
|
||||
|
||||
// get voice channel
|
||||
const picking = interaction.guild.channels.cache.find(
|
||||
(channel) => channel.name === "picking" || channel.id === PICKING_ID
|
||||
);
|
||||
if (!picking) return console.error("Can't find channel 'picking'!");
|
||||
|
||||
// set role name
|
||||
let roleName = command;
|
||||
if (command === "demoman") roleName = "demo";
|
||||
if (command === "engi") roleName = "engineer";
|
||||
|
||||
// check each member in picking channel for role
|
||||
let str = "In picking:";
|
||||
for (const member of picking.members.values()) {
|
||||
if (member.roles.cache.find((role) => role.name === roleName)) {
|
||||
if (str !== "In picking:") str += ",";
|
||||
str += " " + member.user.globalName;
|
||||
}
|
||||
}
|
||||
if (str === "In picking:") str = "¯\\_(ツ)_/¯";
|
||||
|
||||
// respond
|
||||
return await interaction.editReply({
|
||||
content: str,
|
||||
});
|
||||
}
|
||||
|
||||
if (interaction.channelId !== COMMAND_CHANNEL_ID) {
|
||||
await interaction.reply({
|
||||
content: "wrong channel, or you lack the required permissions",
|
||||
@ -85,7 +131,7 @@ client.on("interactionCreate", async (interaction) => {
|
||||
return await interaction.editReply({
|
||||
content: `moved members in ${
|
||||
command === "resetteams" ? "blu" : "addup, blu,"
|
||||
} and red.${eCount > 0 ? ` (error moving ${eCount} members)` : ""}`,
|
||||
} and red${eCount > 0 ? ` (error moving ${eCount} members)` : ""}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
46
register.js
46
register.js
@ -25,7 +25,51 @@ const commands = [
|
||||
{
|
||||
name: "fk",
|
||||
description: "Pulls addup channel members into fk channel and lists them",
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "scout",
|
||||
description: "Lists picking channel members with scout role",
|
||||
},
|
||||
{
|
||||
name: "soldier",
|
||||
description: "Lists picking channel members with soldier role",
|
||||
},
|
||||
{
|
||||
name: "pyro",
|
||||
description: "Lists picking channel members with pyro role",
|
||||
},
|
||||
{
|
||||
name: "demo",
|
||||
description: "Lists picking channel members with demo role",
|
||||
},
|
||||
{
|
||||
name: "demoman",
|
||||
description: "Alias of /demo",
|
||||
},
|
||||
{
|
||||
name: "heavy",
|
||||
description: "Lists picking channel members with heavy role",
|
||||
},
|
||||
{
|
||||
name: "engineer",
|
||||
description: "Lists picking channel members with engineer role",
|
||||
},
|
||||
{
|
||||
name: "engi",
|
||||
description: "Alias of /engineer",
|
||||
},
|
||||
{
|
||||
name: "medic",
|
||||
description: "Lists picking channel members with medic role",
|
||||
},
|
||||
{
|
||||
name: "sniper",
|
||||
description: "Lists picking channel members with sniper role",
|
||||
},
|
||||
{
|
||||
name: "spy",
|
||||
description: "Lists picking channel members with spy role",
|
||||
},
|
||||
];
|
||||
|
||||
const rest = new REST({ version: "10" }).setToken(TOKEN);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user