Compare commits
No commits in common. "f7549776f68498578c282548b1055c8ad57f52ad" and "4f0b35c7ad98c37d0cfa46b6a2d8f6691b5626df" have entirely different histories.
f7549776f6
...
4f0b35c7ad
155
index.js
155
index.js
@ -1,5 +1,5 @@
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import path, { parse } from "path";
|
import path from "path";
|
||||||
import { Client, GatewayIntentBits, Partials } from "discord.js";
|
import { Client, GatewayIntentBits, Partials } from "discord.js";
|
||||||
const {
|
const {
|
||||||
TOKEN,
|
TOKEN,
|
||||||
@ -363,129 +363,6 @@ client.on("interactionCreate", async (interaction) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (command === "fk" || command === "fatkid") {
|
if (command === "fk" || command === "fatkid") {
|
||||||
// pull users in addup into picking, then randomly select other users in picking to be sat out until there are 18 in picking
|
|
||||||
await interaction.reply("Randomly choosing fatkids from picking...");
|
|
||||||
|
|
||||||
// get voice channels
|
|
||||||
const addup = interaction.guild.channels.cache.find(
|
|
||||||
(channel) => channel.name === "add-up" || channel.id === ADDUP_ID
|
|
||||||
);
|
|
||||||
const picking = interaction.guild.channels.cache.find(
|
|
||||||
(channel) => channel.name === "picking" || channel.id === PICKING_ID
|
|
||||||
);
|
|
||||||
|
|
||||||
// get members in voice channel
|
|
||||||
const addupPlayers = Array.from(addup.members.values());
|
|
||||||
if (addupPlayers.length === 0) {
|
|
||||||
return await interaction.followUp("Found no players in addup");
|
|
||||||
}
|
|
||||||
const pickingPlayers = Array.from(picking.members.values());
|
|
||||||
if (pickingPlayers.length === 0) {
|
|
||||||
return await interaction.followUp("Found no players in picking");
|
|
||||||
}
|
|
||||||
|
|
||||||
let fatkids = [];
|
|
||||||
|
|
||||||
// select excess players to be sat out
|
|
||||||
while (pickingPlayers.length + addupPlayers.length > 18) {
|
|
||||||
const idx = Math.floor(Math.random() * pickingPlayers.length);
|
|
||||||
fatkids.push(pickingPlayers.splice(idx, 1)[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
let errCount = 0;
|
|
||||||
|
|
||||||
// move players from addup to picking
|
|
||||||
for (const newPlayer of addupPlayers) {
|
|
||||||
try {
|
|
||||||
await newPlayer.voice.setChannel(picking);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
errCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// move players from picking to fatkid
|
|
||||||
for (const fk of fatkids) {
|
|
||||||
try {
|
|
||||||
if (picking.members.size <= 18) break;
|
|
||||||
await fk.voice.setChannel(addup);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
errCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interaction.followUp(
|
|
||||||
`Sat out ${fatkids.length} players${
|
|
||||||
errCount > 0 ? ` (error moving ${errCount} members)` : ""
|
|
||||||
}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*if (command === "testfk") {
|
|
||||||
// debug fk
|
|
||||||
// pull users in addup into picking, then randomly select other users in picking to be sat out until there are 18 in picking
|
|
||||||
await interaction.reply("Randomly choosing fatkids from picking...");
|
|
||||||
|
|
||||||
// get voice channels
|
|
||||||
const addup = interaction.guild.channels.cache.find(
|
|
||||||
(channel) => channel.name === "add-up" || channel.id === ADDUP_ID
|
|
||||||
);
|
|
||||||
const picking = interaction.guild.channels.cache.find(
|
|
||||||
(channel) => channel.name === "picking" || channel.id === PICKING_ID
|
|
||||||
);
|
|
||||||
|
|
||||||
// get members in voice channel
|
|
||||||
const addupPlayers = Array.from(addup.members.values());
|
|
||||||
if (addupPlayers.length === 0) {
|
|
||||||
return await interaction.followUp("Found no players in addup");
|
|
||||||
}
|
|
||||||
const pickingPlayers = Array.from(picking.members.values());
|
|
||||||
if (pickingPlayers.length === 0) {
|
|
||||||
return await interaction.followUp("Found no players in picking");
|
|
||||||
}
|
|
||||||
|
|
||||||
let fatkids = [];
|
|
||||||
|
|
||||||
// select excess players to be sat out
|
|
||||||
while (pickingPlayers.length + addupPlayers.length > 2) {
|
|
||||||
const idx = Math.floor(Math.random() * pickingPlayers.length);
|
|
||||||
fatkids.push(pickingPlayers.splice(idx, 1)[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
let errCount = 0;
|
|
||||||
|
|
||||||
// move players from addup to picking
|
|
||||||
for (const newPlayer of addupPlayers) {
|
|
||||||
try {
|
|
||||||
await newPlayer.voice.setChannel(picking);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
errCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// move players from picking to fatkid
|
|
||||||
for (const fk of fatkids) {
|
|
||||||
try {
|
|
||||||
console.log(addup.members.size, picking.members.size)
|
|
||||||
if (picking.members.size <= 2) break;
|
|
||||||
await fk.voice.setChannel(addup);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
errCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interaction.followUp(
|
|
||||||
`Sat out ${fatkids.length} players${
|
|
||||||
errCount > 0 ? ` (error moving ${errCount} members)` : ""
|
|
||||||
}`
|
|
||||||
);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (command === "fklist" || command === "listfk") {
|
|
||||||
// moves players in picking to fatkid channel, for use in captain pugs
|
|
||||||
await interaction.reply("Moving fatkids...");
|
await interaction.reply("Moving fatkids...");
|
||||||
|
|
||||||
// get voice channels
|
// get voice channels
|
||||||
@ -671,7 +548,7 @@ client.on("interactionCreate", async (interaction) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interaction.followUp(
|
interaction.followUp(
|
||||||
`Players moved into teams${
|
`Teams selected and moved${
|
||||||
moveErr > 0 ? ` (error moving ${moveErr} members)` : ""
|
moveErr > 0 ? ` (error moving ${moveErr} members)` : ""
|
||||||
}`
|
}`
|
||||||
);
|
);
|
||||||
@ -858,34 +735,6 @@ client.on("messageCreate", async (message) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0] === "fun") {
|
|
||||||
if (
|
|
||||||
args.length < 2 ||
|
|
||||||
isNaN(args[1]) ||
|
|
||||||
parseInt(args[1]) < 1 ||
|
|
||||||
parseInt(args[1]) > 10
|
|
||||||
)
|
|
||||||
return await message.reply(
|
|
||||||
`Current FUN value: ${funInput}\nUsage: \`fun <1-10>\``
|
|
||||||
);
|
|
||||||
funInput = parseInt(args[1]);
|
|
||||||
return await message.reply(`FUN value set to ${funInput}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0] === "passion") {
|
|
||||||
if (
|
|
||||||
args.length < 2 ||
|
|
||||||
isNaN(args[1]) ||
|
|
||||||
parseInt(args[1]) < 1 ||
|
|
||||||
parseInt(args[1]) > 5
|
|
||||||
)
|
|
||||||
return await message.reply(
|
|
||||||
`Current PASSION: ${passionInput}\nUsage: \`passion <1-5>\``
|
|
||||||
);
|
|
||||||
passionInput = parseInt(args[1]);
|
|
||||||
return await message.reply(`PASSION set to ${passionInput}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0] === "simulateteams") {
|
if (args[0] === "simulateteams") {
|
||||||
await message.reply("Simulating teams...");
|
await message.reply("Simulating teams...");
|
||||||
|
|
||||||
|
|||||||
27
register.js
27
register.js
@ -1,5 +1,5 @@
|
|||||||
import { REST, Routes } from "discord.js";
|
import { REST, Routes } from "discord.js";
|
||||||
const { TOKEN, CLIENT_ID, GUILD_ID } = require("./config.json");
|
const { TOKEN, CLIENT_ID } = require("./config.json");
|
||||||
|
|
||||||
const commands = [
|
const commands = [
|
||||||
{
|
{
|
||||||
@ -20,22 +20,10 @@ const commands = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "fatkid",
|
name: "fatkid",
|
||||||
description: "Moves added players to picking and randomly selects fatkids",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "fk",
|
|
||||||
description: "Moves added players to picking and randomly selects fatkids",
|
|
||||||
},
|
|
||||||
/*{
|
|
||||||
name: "testfk",
|
|
||||||
description: "debug fk",
|
|
||||||
},*/
|
|
||||||
{
|
|
||||||
name: "fklist",
|
|
||||||
description: "Pulls addup channel members into fk channel and lists them",
|
description: "Pulls addup channel members into fk channel and lists them",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "listfk",
|
name: "fk",
|
||||||
description: "Pulls addup channel members into fk channel and lists them",
|
description: "Pulls addup channel members into fk channel and lists them",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -105,21 +93,10 @@ const rest = new REST({ version: "10" }).setToken(TOKEN);
|
|||||||
try {
|
try {
|
||||||
console.log("Started refreshing application (/) commands.");
|
console.log("Started refreshing application (/) commands.");
|
||||||
|
|
||||||
// application reload
|
|
||||||
await rest.put(Routes.applicationCommands(CLIENT_ID), {
|
await rest.put(Routes.applicationCommands(CLIENT_ID), {
|
||||||
body: commands,
|
body: commands,
|
||||||
});
|
});
|
||||||
|
|
||||||
// guild reload, faster than application reload
|
|
||||||
//await rest.put(Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), {
|
|
||||||
// body: commands,
|
|
||||||
//});
|
|
||||||
|
|
||||||
// clear guild commands
|
|
||||||
//await rest.put(Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), {
|
|
||||||
// body: [],
|
|
||||||
//});
|
|
||||||
|
|
||||||
console.log("Successfully reloaded application (/) commands.");
|
console.log("Successfully reloaded application (/) commands.");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user