wip: debug fk failure to move to addup

This commit is contained in:
ethanf 2024-01-31 01:41:55 -06:00
parent f2406d8eeb
commit fc7a49faff
2 changed files with 13 additions and 10 deletions

View File

@ -411,7 +411,7 @@ client.on("interactionCreate", async (interaction) => {
// move players from picking to fatkid
for (const fk of fatkids) {
try {
if (picking.members.size <= 18) break;
//if (picking.members.size <= 18) break;
await fk.voice.setChannel(addup);
} catch (error) {
console.error(error);
@ -426,7 +426,7 @@ client.on("interactionCreate", async (interaction) => {
);
}
/*if (command === "testfk") {
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...");
@ -441,8 +441,8 @@ client.on("interactionCreate", async (interaction) => {
// 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");
if (addupPlayers.length === 0 && pickingPlayers.length <= 2) {
return await interaction.followUp("Found no players in addup and picking has 18 or fewer players");
}
const pickingPlayers = Array.from(picking.members.values());
if (pickingPlayers.length === 0) {
@ -452,9 +452,13 @@ client.on("interactionCreate", async (interaction) => {
let fatkids = [];
// select excess players to be sat out
console.log(pickingPlayers.length, addupPlayers.length, pickingPlayers.length + addupPlayers.length)
while (pickingPlayers.length + addupPlayers.length > 2) {
const idx = Math.floor(Math.random() * pickingPlayers.length);
fatkids.push(pickingPlayers.splice(idx, 1)[0]);
let fk = await pickingPlayers.splice(idx, 1)[0];
console.log(getApplicableName(fk))
fatkids.push(fk);
}
let errCount = 0;
@ -472,8 +476,7 @@ client.on("interactionCreate", async (interaction) => {
// 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;
// if (picking.members.size <= 18) break;
await fk.voice.setChannel(addup);
} catch (error) {
console.error(error);
@ -486,7 +489,7 @@ client.on("interactionCreate", async (interaction) => {
errCount > 0 ? ` (error moving ${errCount} members)` : ""
}`
);
}*/
}
if (command === "fklist" || command === "listfk") {
// moves players in picking to fatkid channel, for use in captain pugs

View File

@ -26,10 +26,10 @@ const commands = [
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",