0

I have a simple command that mentions a random user in a text channel. It worked perfectly for weeks, until today.

TL;DR: channel.members is a map that used to contain all of the users of the text channel, but not anymore. Is there an error on my side or has something changed?

Before today, map would correctly contain all users that are in a text channel where message event happened. Now, for some reason, in this map there is an author and a bot itself + seemingly random people.

At first he seemed to also include people in a voice channel, and now nobody is in any of the voice channels and after the first message there was only me and a bot in the map, and when I asked someone to do a command, then he also has appeared in the map.

So that made me think that the channel property from message event's arg might have a map of people that messaged anything while bot was live, but how would that explain the people from the voice channel? Furthermore, before today, he would randomize anyone, even the people that have never posted a single message in any of the channels, ever.

Has Discord API changed recently? Because I cannot find any announcement or anything like that and I have no idea why it doesn't work anymore. I even checked out to few commits ranging from yesterday to couple days ago and it still behaves this way.

I double checked everything and I'm sure I have people that didn't say anything anywhere, and I see that bot has mentioned these people last time at 28 of October.

main.js

bot.on('message', message => {
    if (!message.content.startsWith(prefix) || message.author.bot) return;
    require(`./commands/random_member`).execute(message, null);
});

random_member.js

module.exports = {
    name: 'random_member',
    usage: 'random_member',
    description: "random_member",
    execute(message, args) {
        const member = message.channel.members.random();
        message.channel.send(`${member}`);
    }
}
Hakej
  • 414
  • 4
  • 8
  • 1
    I think you might have a similar problem to this https://stackoverflow.com/questions/64559390/none-of-my-discord-js-guildmember-events-are-emitting-my-user-caches-are-basica – Worthy Alpaca Oct 29 '20 at 23:37

1 Answers1

0

Worthy Alpaca helped me with his comment.

"Firstly, you must manually enable the intents from the Discord Developer site. Go to applications, select your app, and find the "bot" tab on the sidebar. Then you can scroll down until you see this:"

enter image description here

I've enabled both of the options and my issues have disappeared.

Source: None of my discord.js guildmember events are emitting, my user caches are basically empty, and my functions are timing out?

Hakej
  • 414
  • 4
  • 8