Reputation: 17
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
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