Skip to content
Advertisement

Tag: discord.js

How can I sort this array in Discord.js?

I have an array, that looks like this(size changes): The first value is the member id, the second how many messages the user has. How can I sort the array, to get the first 10 members, sorted by their messages send? The code: Answer To sort an array by numbers, you can use the .sort() method with a compare function

Can I randomize message replies? (Discord.js)

What I am trying to do is randomize messages, i don’t know how though. I’ve been using the code: I’m wondering if it is possible to make it send random replies when a command is executed on Discord. Answer You can defined list of answer in array and random of one those answer Ex:

Discord.js | Chatbot responds to command name

so I’m trying to make a chatbot that sends the message after the user types the prefix and the command name. The command works in general but it seems to also take in the command name. I use a command and event handler btw. This is what it looks like: So when people do a.chat without an arg after that,

Discord JS Client only has itself in guild members cache

So I was trying to access a member from a guild via but when the bot starts up the guild only contains itself until a user sends a message. Answer You need to enable member fetch When creating the client client = new Client({fetchAllMembers: true}} Do note that calling Fetch() on a guild Will Overwrite the internal cached guild.

Advertisement