mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-19 13:56:43 +02:00
Fix
This commit is contained in:
@@ -2,7 +2,7 @@ const Command = require('../../framework/Command');
|
|||||||
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
|
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
const { removeDuplicates, removeFromArray, shuffle } = require('../../util/Util');
|
const { removeDuplicates, removeAllFromArray, shuffle } = require('../../util/Util');
|
||||||
const events = require('../../assets/json/hunger-games');
|
const events = require('../../assets/json/hunger-games');
|
||||||
|
|
||||||
module.exports = class HungerGamesCommand extends Command {
|
module.exports = class HungerGamesCommand extends Command {
|
||||||
@@ -118,7 +118,7 @@ module.exports = class HungerGamesCommand extends Command {
|
|||||||
const tribute = tributes.get(tributeKey);
|
const tribute = tributes.get(tributeKey);
|
||||||
if (!turn.has(tribute.name)) continue;
|
if (!turn.has(tribute.name)) continue;
|
||||||
let types = this.decideTypes(tribute);
|
let types = this.decideTypes(tribute);
|
||||||
if (turn.size === 1) types = removeFromArray(types, 'kill');
|
if (turn.size === 1) types = removeAllFromArray(types, 'kill');
|
||||||
const type = types[Math.floor(Math.random() * types.length)];
|
const type = types[Math.floor(Math.random() * types.length)];
|
||||||
const useWeapon = Math.floor(Math.random() * 3);
|
const useWeapon = Math.floor(Math.random() * 3);
|
||||||
const valid = eventsArr.filter(event => {
|
const valid = eventsArr.filter(event => {
|
||||||
|
|||||||
@@ -61,6 +61,12 @@ module.exports = class Util {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static removeFromArray(arr, value) {
|
static removeFromArray(arr, value) {
|
||||||
|
const index = arr.indexOf(value);
|
||||||
|
if (index > -1) return arr.splice(index, 1);
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static removeAllFromArray(arr, value) {
|
||||||
return arr.filter(i => i !== value);
|
return arr.filter(i => i !== value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user