The command I set up just grabs a random user to spice up the message a bit. I had to fix something last night and when I restarted the bot, it is now only getting anyone that has messaged. Before, it was getting any random person in the server like it's supposed to. I have also tried to use
message.guild.members.cache.random();
with the same results. Here is the rest of the code from that command
const Discord = require('discord.js');
const fs = require('fs');
const colors = require('../../colors.json');
const candyAmount = require('../../candyheld.json');
const client = new Discord.Client();
module.exports = {
name: 'trickortreat',
description: 'Special Halloween command',
execute(message, args) {
if (!candyAmount[message.author.id]) {
candyAmount[message.author.id] = {
candyStored: 5
}
fs.writeFile('./candyheld.json', JSON.stringify(candyAmount), err => {
if (err) console.error(err);
});
message.delete();
return message.channel.send('For starting the event, you have been given 5 pieces of candy!');
}
// Stores a random number of candy from 1-3
let candyGiven = Math.floor(Math.random() * 3 + 1);
let jackpot = Math.floor(Math.random() * 10 + 20 );
let highJackpot = Math.floor(Math.random() * 100 + 200);
let randomMember = message.client.users.cache.random();
// Sets the possible messages to be received
let trickortreatmessage = [
'The scarecrow standing behind you jumps out at you and makes you drop all your candy!',
`${randomMember} was nice enough to give you Candy! ${message.author} got ${candyGiven} pieces of candy!`,
`Oh no! ${message.author} asked ${randomMember} for Candy and they decided to egg you instead!`,
`The Headless Horseman rides and slashes his way to every bin of candy all just to give you everything he got!\n\n${message.author} got ${jackpot} Candy!`,
`The wolves howl in sync as Candy rains from the sky! The adrenaline makes you move at lightning speed to grab every piece of Candy!\n\n ${message.author} got ${highJackpot} Candy!!!`
]
// Store one of the random messages
let trickortreat;
let odds = Math.floor(Math.random() * 5000);
if (odds <= 25) trickortreat = trickortreatmessage[4]; // .5% chance
else if (odds <= 49) trickortreat = trickortreatmessage[0]; // .5% chance
else if (odds <= 499) trickortreat = trickortreatmessage[3]; // 9% chance
else if (odds <= 1999) trickortreat = trickortreatmessage[2]; // 30% chance
else trickortreat = trickortreatmessage[1]; // 60% chance
if (trickortreat == trickortreatmessage[0]) {
candyAmount[message.author.id].candyStored = 0;
} else if (trickortreat == trickortreatmessage[1]) {
candyAmount[message.author.id].candyStored += candyGiven;
} else if (trickortreat == trickortreatmessage[3]) {
candyAmount[message.author.id].candyStored += jackpot;
} else if (trickortreat == trickortreatmessage[4]) {
candyAmount[message.author.id].candyStored += highJackpot;
}
fs.writeFile('./candyheld.json', JSON.stringify(candyAmount), err => {
if (err) console.error(err);
});
const embed = new Discord.MessageEmbed()
.setColor(colors.serverRed)
.addField('\u200B', `**${trickortreat}**`)
message.delete();
message.channel.send(embed);
},
};