Compare commits

..

No commits in common. "1c53aeeeeef14f25319e609c3e66231db6a10d20" and "949a08956abb226355ccbb90a7f902fd62c886f0" have entirely different histories.

4 changed files with 33 additions and 53 deletions

View File

@ -4,7 +4,6 @@
"GUILD_ID": "658490352189046784",
"COMMAND_CHANNEL_ID": "1177469184192565288",
"ADDUP_ID": "1175649994674544721",
"PICKING_ID": "1175649967935856680",
"BLU_ID": "1175649793943552010",
"RED_ID": "1175649777648680971",
"FK_ID": "1176396207183106078"

View File

@ -1,13 +1,5 @@
import { Client, GatewayIntentBits } from "discord.js";
const {
TOKEN,
COMMAND_CHANNEL_ID,
ADDUP_ID,
PICKING_ID,
BLU_ID,
RED_ID,
FK_ID,
} = require("./config.json");
const { TOKEN, COMMAND_CHANNEL_ID, ADDUP_ID, BLU_ID, RED_ID, FK_ID } = require("./config.json");
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates],
@ -18,7 +10,6 @@ client.on("ready", () => {
});
client.on("interactionCreate", async (interaction) => {
const command = interaction.commandName;
if (!interaction.isChatInputCommand()) return;
if (interaction.channelId !== COMMAND_CHANNEL_ID) {
@ -29,16 +20,15 @@ client.on("interactionCreate", async (interaction) => {
return;
}
if (command === "hello") {
if (interaction.commandName === "hello") {
await interaction.reply("world");
}
if (
command === "topicking" ||
command === "end" ||
command === "resetteams"
interaction.commandName === "pullTeams" ||
interaction.commandName === "end"
) {
await interaction.deferReply();
await interaction.deferReply({ ephemeral: true });
// get voice channels
const blu = interaction.guild.channels.cache.find(
@ -53,20 +43,11 @@ client.on("interactionCreate", async (interaction) => {
(channel) => channel.name === "add-up" || channel.id === ADDUP_ID
);
if (!addup) return console.error("Can't find channel 'add-up'!");
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'!");
// get members in voice channel
let members = blu.members.concat(red.members);
if (commandName !== "resetteams") members = members.concat(addup.members);
const members = blu.members.concat(red.members);
if (members.size === 0) {
return await interaction.editReply(
`found no members in ${
command === "resetteams" ? "blu" : "addup, blu,"
} or red`
);
return await interaction.editReply("found no members in teams");
}
// move members to addup
@ -75,39 +56,45 @@ client.on("interactionCreate", async (interaction) => {
members.forEach(async (member) => {
idx++;
try {
await member.voice.setChannel(picking);
await member.voice.setChannel(addup);
} catch (error) {
console.error(error);
eCount++;
} finally {
// respond when done
if (idx === members.size) {
if (eCount > 0) {
return await interaction.editReply({
content: `moved teams, error moving ${eCount} members`,
});
}
return await interaction.editReply({
content: `moved members in ${
command === "resetteams" ? "blu" : "addup, blu,"
} and red.${eCount > 0 ? ` (error moving ${eCount} members)` : ""}`,
content: `moved teams`,
});
}
}
});
}
if (command === "fk" || command === "fatkid") {
if (
interaction.commandName === "fk" ||
interaction.commandName === "fatkid"
) {
await interaction.deferReply();
// get voice channels
const picking = interaction.guild.channels.cache.find(
(channel) => channel.name === "picking" || channel.id === PICKING_ID
const addup = interaction.guild.channels.cache.find(
(channel) => channel.name === "add-up" || channel.id === ADDUP_ID
);
if (!picking) return console.error("Can't find channel 'add-up'!");
if (!addup) return console.error("Can't find channel 'add-up'!");
const fk = interaction.guild.channels.cache.find(
(channel) => channel.name === "fatkid" || channel.id === FK_ID
);
if (!fk) return console.error("Can't find channel 'fatkid'!");
const members = picking.members;
const members = addup.members;
if (members.size === 0) {
return await interaction.editReply("found no members in picking");
return await interaction.editReply("found no members in addup");
}
// get members in voice channel
@ -128,13 +115,11 @@ client.on("interactionCreate", async (interaction) => {
if (idx === members.size) {
if (eCount > 0) {
return await interaction.editReply({
content: `fatkids: ${str}`,
content: `fatkids: ${str}, error moving ${eCount} members`,
});
}
return await interaction.editReply({
content: `fatkids: ${str}${
eCount > 0 ? ` (error moving ${eCount} members)` : ""
}`,
content: `fatkids: ${str}`,
});
}
}

View File

@ -1,6 +1,6 @@
{ "dependencies": { "discord.js": "^14.14.1" },
"scripts": {
"start": "bun --watch index.js",
"register": "bun register.js"
"start": "bun run index.js",
"register": "bun run register.js"
}
}

View File

@ -1,5 +1,5 @@
import { REST, Routes } from "discord.js";
const { TOKEN, CLIENT_ID } = require("./config.json");
const { token, client_id } = require("./config.json");
const commands = [
{
@ -7,16 +7,12 @@ const commands = [
description: "Replies 'world'",
},
{
name: "topicking",
description: "Pulls team and addup channel members into picking channel",
name: "pullteams",
description: "Pulls team channel members into addup channel",
},
{
name: "end",
description: "Pulls team and addup channel members into picking channel",
},
{
name: "resetteams",
description: "Pulls team channel members into picking channel",
description: "Pulls team channel members into addup channel",
},
{
name: "fatkid",
@ -28,12 +24,12 @@ const commands = [
}
];
const rest = new REST({ version: "10" }).setToken(TOKEN);
const rest = new REST({ version: "10" }).setToken(token);
try {
console.log("Started refreshing application (/) commands.");
await rest.put(Routes.applicationCommands(CLIENT_ID), {
await rest.put(Routes.applicationCommands(client_id), {
body: commands,
});