feat: only picking or captains allowed to /class

This commit is contained in:
ethanf 2023-11-30 18:10:22 -06:00
parent d266ac622c
commit 04fad613b6
2 changed files with 40 additions and 22 deletions

View File

@ -7,5 +7,6 @@
"PICKING_ID": "1175649967935856680", "PICKING_ID": "1175649967935856680",
"BLU_ID": "1175649793943552010", "BLU_ID": "1175649793943552010",
"RED_ID": "1175649777648680971", "RED_ID": "1175649777648680971",
"FK_ID": "1176396207183106078" "FK_ID": "1176396207183106078",
"CAPTAIN_ID": "1178475124563919018"
} }

View File

@ -7,13 +7,14 @@ const {
BLU_ID, BLU_ID,
RED_ID, RED_ID,
FK_ID, FK_ID,
CAPTAIN_ID,
} = require("./config.json"); } = require("./config.json");
const client = new Client({ const client = new Client({
intents: [ intents: [
GatewayIntentBits.Guilds, GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildVoiceStates GatewayIntentBits.GuildVoiceStates,
], ],
}); });
@ -38,13 +39,28 @@ client.on("interactionCreate", async (interaction) => {
command === "sniper" || command === "sniper" ||
command === "spy" command === "spy"
) { ) {
await interaction.deferReply(); // get voice channels
// get voice channel
const picking = interaction.guild.channels.cache.find( const picking = interaction.guild.channels.cache.find(
(channel) => channel.name === "picking" || channel.id === PICKING_ID (channel) => channel.name === "picking" || channel.id === PICKING_ID
); );
if (!picking) return console.error("Can't find channel 'picking'!"); if (!picking) return console.error("Can't find channel 'picking'!");
const captain = interaction.guild.channels.cache.find(
(channel) => channel.name === "captains" || channel.id === CAPTAIN_ID
);
if (!captain) return console.error("Can't find channel 'captains'!");
// make sure user is in picking or captain channel
if (
!picking.members.has(interaction.user.id) &&
!captain.members.has(interaction.user.id)
) {
await interaction.reply({
content: "must be in picking or captains channel to use this command",
ephemeral: true,
});
return;
} else {
await interaction.deferReply();
// set role name // set role name
let roleName = command; let roleName = command;
@ -59,13 +75,14 @@ client.on("interactionCreate", async (interaction) => {
str += " " + member.user.globalName; str += " " + member.user.globalName;
} }
} }
if (str === "In picking:") str = "¯\\_(ツ)_/¯"; if (str === "In picking:") str = "None found ¯\\_(ツ)_/¯";
// respond // respond
return await interaction.editReply({ return await interaction.editReply({
content: str, content: str,
}); });
} }
}
if (interaction.channelId !== COMMAND_CHANNEL_ID) { if (interaction.channelId !== COMMAND_CHANNEL_ID) {
await interaction.reply({ await interaction.reply({