args.pick issue
Code:
Error:
TypeError: Cannot read properties of undefined (reading 'cache')
idk why it isn't updating the user variable, I logged user inside the if and it returns a User object11 Replies
The default shouldn't be
message.member.user
(which is the same thing as message.author
, by the way), it should be message.member
Member objects are specific to guilds and thus have roles, nicknames, etc. Users are global.was it updated or something? it was working without any problem some weeks ago
It was definitely not updated
maybe you just never had it use the fallback arg before
now if the user provided has no roles it will just return my roles (or the roles of the person that ran the command)
That looks to be what the code does. What are you trying to make it do?
to show the roles of the provided user
if no user is provided then the roles of the author
but wouldn't
user
already do thatnow if the user provided has no roles it will just return my roles (or the roles of the person that ran the command)It sounds like that fits your description?
no? it should say "User has no roles." instead
You need to convert the value to a string before the
|| "..."
otherwise it's just randomArray || "..."
, and the array is always truthy
what's not truthy is an empty string, so convert it to a strip first with .toString()
or .join(',')
like this?
didn't work so changed the args.pick to a
message.guild.members.cache.get(user.id)
last question, do you know how to order the roles in the order that are in the server
rn .sort((a, b) => a.localeCompare(b))
sorts them alphabeticallydiscord.js
discord.js
discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.