fix: compare exception id to id instead of member to user
This commit is contained in:
parent
9feac9211f
commit
6673965c3e
@ -1,4 +1,5 @@
|
|||||||
import { SlashCommandBuilder } from "discord.js";
|
import { SlashCommandBuilder } from "discord.js";
|
||||||
|
import { findChannelfromCache } from "../utils";
|
||||||
import { ROLE_ID_RUNNER, VOICE_ID_ADDUP, VOICE_ID_PICKING } from "../config.json";
|
import { ROLE_ID_RUNNER, VOICE_ID_ADDUP, VOICE_ID_PICKING } from "../config.json";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
@ -63,12 +64,19 @@ const execute = async (interaction) => {
|
|||||||
await interaction.reply("Randomly choosing fatkids from picking...");
|
await interaction.reply("Randomly choosing fatkids from picking...");
|
||||||
|
|
||||||
// get voice channels
|
// get voice channels
|
||||||
const addup = interaction.guild.channels.cache.find(
|
const addup = findChannelfromCache(
|
||||||
(channel) => channel.name === "add-up" || channel.id === VOICE_ID_ADDUP
|
interaction.guild.channels.cache,
|
||||||
|
"add-up",
|
||||||
|
VOICE_ID_ADDUP
|
||||||
);
|
);
|
||||||
const picking = interaction.guild.channels.cache.find(
|
const picking = findChannelfromCache(
|
||||||
(channel) => channel.name === "picking" || channel.id === VOICE_ID_PICKING
|
interaction.guild.channels.cache,
|
||||||
|
"picking",
|
||||||
|
VOICE_ID_PICKING
|
||||||
);
|
);
|
||||||
|
if (!addup || !picking) {
|
||||||
|
return console.error("Could not find all channels for /fk");
|
||||||
|
}
|
||||||
|
|
||||||
// get members in voice channel
|
// get members in voice channel
|
||||||
const addupPlayers = [];
|
const addupPlayers = [];
|
||||||
@ -115,7 +123,7 @@ const execute = async (interaction) => {
|
|||||||
let exceptions = [];
|
let exceptions = [];
|
||||||
for (const option of ["exception1", "exception2"]) {
|
for (const option of ["exception1", "exception2"]) {
|
||||||
const exception = interaction.options.getUser(option);
|
const exception = interaction.options.getUser(option);
|
||||||
if (exception) exceptions.push(exception);
|
if (exception) exceptions.push(exception.id);
|
||||||
}
|
}
|
||||||
if (addupPlayers.length > targetPlayerCount - exceptions.length) {
|
if (addupPlayers.length > targetPlayerCount - exceptions.length) {
|
||||||
exceptions = [];
|
exceptions = [];
|
||||||
@ -140,7 +148,7 @@ const execute = async (interaction) => {
|
|||||||
fkAttempts++;
|
fkAttempts++;
|
||||||
const idx = Math.floor(Math.random() * pickingPlayers.length);
|
const idx = Math.floor(Math.random() * pickingPlayers.length);
|
||||||
let fk = pickingPlayers[idx];
|
let fk = pickingPlayers[idx];
|
||||||
if (exceptions.includes(fk)) {
|
if (exceptions.includes(fk.id)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (protectedFk.includes(fk.id)) {
|
if (protectedFk.includes(fk.id)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user