Rabzy
Rabzy

Reputation: 17

Trying to get a discord bot to pick a random user

I am attempting to make a bot that will print a random user for my discord channel. The problem is that I keep getting weird errors while in the bot.on function. I am trying to use the code var randomUser = message.guild.name.random(); however this returns:

C:\Users\Robert\Desktop\Discord Bot\index.js:18       
        var randomUser = message.guild.name.random(); 
                                            ^

TypeError: message.guild.name.random is not a function

Please Help!

Upvotes: 0

Views: 4119

Answers (1)

Syntle
Syntle

Reputation: 5174

guild.name returns the name of the guild, not the collection of it's members. your solution is:

v11

var randomUser = message.guild.members.random();

v12

var randomUser = message.guild.members.cache.random();

Upvotes: 2

Related Questions