Search code examples
javascriptnode.jsdiscorddiscord.js

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

  • 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.