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
Tag: discord.js
How to replace switch with Object literals
When i rewriting my old code, i had a problem i don’t know to to optimize this code in past i use switch,but now i know about Object literals, my code: How i can replace him with object literals? Answer You can write the cases as object literals and iterate over them:
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:
Clear all messages that are not images or links by using discord.js and Node.js [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 1 year ago. Improve this question I have a bot in discord in JavaScript and I need to start a timer in 24 hours and clear
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.
How do I make a reaction log?
I wan’t to make a reaction log for my server, but I keep getting undefined. Here’s the code: Answer You need to get the property channel from messageReaction.message Documentation on MessageReactionAdd
how do i filter a data in quickmongoi so that it would show only names of users who are in the guild only in the leaderboard command
js and quickmongo for a leaderboard command but it shows the named of all the users in the database and I want it to show names of users who are in the guild only. Any help is highly appreciated 🙏. I tried filtering it too… My current code Help me please Answer Array#filter() doesn’t modify arrays in place, it only
Random picture of cats discord.js Uncaught TypeError: Cannot read property ‘pipe’ of undefined
I am trying to make a bot that sends cat pictures from a cat API but when I run the code it gives an error that I have never seen. When I run the code it returns Uncaught TypeError: Cannot read property ‘pipe’ of undefined. Answer Instead of the low-level xmlhttprequest you could use node-fetch to grab the response from
Unable to read standard emoji name from reaction [discord.js]
Hey I’m doing a bot and I need to get the name of the emoji from the reaction. I did it for now with console.log () but I was surprised because I got some kind of weird badge instead of the emoji name. I got the emoji 🎉 :tada: for the news and I was expecting something like this in