'Grabbing a message mention taking longer than expected (DJS V13)
I'm using message.mentions.members.first()
but the problem is that when I ping a user, the bot replies after a long delay.
Video: https://gyazo.com/a8739e60bb86bc68c680731e3d491fee (bot was on clearly)
I've tried switching between networks, but it's still delayed. Let me know if there are any available fixes.
let member = await message.mentions.members.first()
if (!member) return message.channel.send({ content: "You did not mention a member or that member does not exist." })
if (args[0] = "add") {
let obj = member.id
let bypass = JSON.parse(fs.readFileSync("./bypass.json", "utf-8"))
bypass.push(obj)
fs.writeFile('./bypass.json', JSON.stringify(bypass, null, 4), err => {
if (err) console.log(err);
})
message.channel.send({ content: `Added sus to the bypass list!` })
}
if (args[0] === 'remove') {
let obj
obj = member.id
let table = obj
bypass.push(table)
fs.writeFile('./bypass.json', JSON.stringify(bypass, null, 4), err => {
if (err) console.log(err);
})
}
Solution 1:[1]
Sorry for the extremely long wait for an answer but I figured out how to fix it, turns out a line of code that checks for swear words (i used a npm package for the detection of swear words). That line of code couldn't figure out if it was a swear word or something else. Removed it and worked completely fine. Sorry for the trouble.
Solution 2:[2]
Read through your code and found two mistakes, message.mentions.users is an array, doesn't return a promise, you therefore don't need to use await, as second error, in the first if
statement you only placed one =
, while you need two or three to compare.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | notratz |
Solution 2 | MadMisty |