67 lines
1.6 KiB
JavaScript
67 lines
1.6 KiB
JavaScript
import { SlashCommandBuilder } from "discord.js";
|
|
import { findChannelfromCache, findPlayer, getApplicableName } from "../utils";
|
|
import { RUNNER_ROLE_ID, PICKING_ID, FK_ID } from "../config.json";
|
|
|
|
// not really used since fks are now determined randomly
|
|
const data = new SlashCommandBuilder()
|
|
.setName("fklist")
|
|
.setDescription("Pulls addup channel members into fk channel and lists them");
|
|
|
|
const permissions = [RUNNER_ROLE_ID];
|
|
|
|
const synonyms = ["listfk"];
|
|
|
|
const execute = async (interaction) => {
|
|
await interaction.reply("Moving fatkids...");
|
|
|
|
// get voice channels
|
|
const picking = findChannelfromCache(
|
|
interaction.guild.channels.cache,
|
|
"picking",
|
|
PICKING_ID
|
|
);
|
|
const fk = findChannelfromCache(
|
|
interaction.guild.channels.cache,
|
|
"fatkid",
|
|
FK_ID
|
|
);
|
|
if (!picking || !fk) {
|
|
return console.error("Could not find all channels for /fklist");
|
|
}
|
|
|
|
// get members in voice channel
|
|
const members = picking.members;
|
|
if (members.size === 0) {
|
|
return await interaction.followUp("Found no members in picking");
|
|
}
|
|
|
|
let names = [],
|
|
eCount = 0;
|
|
|
|
const logFk = async (member) => {
|
|
try {
|
|
await member.voice.setChannel(fk);
|
|
names.push(getApplicableName(member));
|
|
} catch (error) {
|
|
console.error(error);
|
|
eCount++;
|
|
}
|
|
};
|
|
|
|
const logAllFks = async () => {
|
|
return Promise.all(
|
|
Array.from(members, async ([memberId, member]) => {
|
|
await logFk(member);
|
|
})
|
|
);
|
|
};
|
|
|
|
logAllFks().then(() =>
|
|
interaction.followUp(
|
|
`Fatkids: ${names.join(', ')}${eCount > 0 ? ` (error moving ${eCount} members)` : ""}`
|
|
)
|
|
);
|
|
};
|
|
|
|
export { data, permissions, execute, synonyms };
|