Michael-J-Scofield / discord-anti-spam

A simple discord anti spam node.js module to prevent spam on your discord server
MIT License
146 stars 53 forks source link

DiscordAPIError: Unknown Message #140

Closed comicallybad closed 3 years ago

comicallybad commented 3 years ago

I tried using this package a long time ago and due to this problem I gave up on trying to use it. I saw that the issue had been "fixed," so I gave it a try again, and I still am getting this issue when there is spam. I spam, I get the warning to please stop spamming, and then crash.

throw new DiscordAPIError(request.path, data, request.method, res.status); ^

DiscordAPIError: Unknown Message at RequestHandler.execute (C:\Users.....\node_modules\discord.js\src\rest\RequestHandler.js:154:13) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async RequestHandler.push (C:\Users.....\node_modules\discord.js\src\rest\RequestHandler.js:39:14) at async MessageManager.delete (C:\Users.....\node_modules\discord.js\src\managers\MessageManager.js:126:5) { method: 'delete', path: '/channels/839381329891164211/messages/890143110783463445', code: 10008, httpStatus: 404 }

I have no other bots deleting messages. So I do not know what is causing it.

image

As you can see, spam, warning message, all messages got deleted before the warning, then app crash.

Scraayp commented 3 years ago

Which version you use?

Scraayp commented 3 years ago

And try doing verbose: false.

comicallybad commented 3 years ago

The antiSpam.message() cannot be within an async function. I think this is pretty annoying, but it is what it is, I found a way around it

Scraayp commented 3 years ago

Why close it than. I will fix it cmon.

Scraayp commented 3 years ago

Coul you please give me your code as hastebin file?

comicallybad commented 3 years ago

This was the original code. My hasPermissions() function commonly will not function without an await. However in this case removing the async and await caused seems to have no effect yet, it has caused me issues before. Don’t mind my useless catch statement I forgot to remove. https://paste.menudocs.org/paste/xz6xz

Scraayp commented 3 years ago

in your antispam options. Try doing verbose: false.

comicallybad commented 3 years ago

in your antispam options. Try doing verbose: false.

I have verbose set to false. Here are my options: client.antiSpam = new AntiSpam({ warnThreshold: 5, muteThreshold: 7, kickThreshold: 99, banThreshold: 99, maxInterval: 2000, warnMessage: '{@user}, Please stop spamming or you will be muted.', kickMessage: '{user_tag} has been kicked for spamming.', muteMessage: '{user_tag} has been muted for spamming.', maxDuplicatesWarning: 6, maxDuplicatesKick: 99, maxDuplicatesBan: 99, maxDuplicatesMute: 8, ignoredPermissions: ['MANAGE_NICKNAMES'], ignoreBots: true, verbose: false, muteRoleName: "Muted", removeMessages: true, removeBotMessages: true, removeBotMessagesAfter: 15000, }); I don’t want to use the kick and ban feature, however I found another issue, if I don’t supply a kick message then the event for mute add does not trigger

Scraayp commented 3 years ago

So unkown message error

I don’t want to use the kick and ban feature, however I found another issue, if I don’t supply a kick message then the event for mute add does not trigger

Scraayp commented 3 years ago

Just for me, so i can see it faster on pr

Scraayp commented 3 years ago

And which version of the package do you use?

comicallybad commented 3 years ago

And which version of the package do you use?

I’m on the version 2.5.8. I’m also on discord.js v12.5.3 so I’m not sure if that could be the issue. Updating to v12 was the most hell experience ever with them changing the message.delete() and now that they’ve changed channel.send() and many other methods, I am not trying to update anytime soon lol.

Scraayp commented 3 years ago

You will need. In april it will be required

As slash commands will be required and some intents changes. Basiclly v12 be closed soon

comicallybad commented 3 years ago

You will need. In april it will be required

That’s gonna be fun then lol rip, so many changes to common methods. I made a global delete function to make that easier. Probably will do the same for send and some other functions.

Scraayp commented 3 years ago

I heard its already deprecated

Scraayp commented 3 years ago

What needs to be done:

Scraayp commented 3 years ago

" I don’t want to use the kick and ban feature, however I found another issue, if I don’t supply a kick message then the event for mute add does not trigger"

I checked the code and this should not be the case! Please make sure nothing else is breaking it.

Scraayp commented 3 years ago

Also unknown message error should be fixed!

comicallybad commented 3 years ago

I am now getting this error consistently:

10-23-2021 01-12-00 A new uncaughtExcemption error: TypeError: Cannot read property 'delete' of undefined
    at Timeout._onTimeout (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\discord-anti-spam\index.js:277:34)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7) at: uncaughtException

and this error

10-23-2021 02-49-19: A new unhandledRejection: at promise [object Promise] TypeError: Cannot read property 'user' of undefined

Both of which seem to be coming from discord-anti-spam, I am trying to log it without my error handler so I can verify, but I did thorough testing and didn't have any issues with my commands. And I get like 15 of those cannot read property 'user' of undefined messages within a couple seconds

Scraayp commented 3 years ago

I am now getting this error consistently:

10-23-2021 01-12-00 A new uncaughtExcemption error: TypeError: Cannot read property 'delete' of undefined
    at Timeout._onTimeout (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\discord-anti-spam\index.js:277:34)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7) at: uncaughtException

and this error

10-23-2021 02-49-19: A new unhandledRejection: at promise [object Promise] TypeError: Cannot read property 'user' of undefined

Both of which seem to be coming from discord-anti-spam, I am trying to log it without my error handler so I can verify, but I did thorough testing and didn't have any issues with my commands. And I get like 15 of those cannot read property 'user' of undefined messages within a couple seconds

Delete the clearbotmessages option. As it doesn't work

comicallybad commented 3 years ago

I am now getting this error consistently:

10-23-2021 01-12-00 A new uncaughtExcemption error: TypeError: Cannot read property 'delete' of undefined
    at Timeout._onTimeout (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\discord-anti-spam\index.js:277:34)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7) at: uncaughtException

and this error

10-23-2021 02-49-19: A new unhandledRejection: at promise [object Promise] TypeError: Cannot read property 'user' of undefined

Both of which seem to be coming from discord-anti-spam, I am trying to log it without my error handler so I can verify, but I did thorough testing and didn't have any issues with my commands. And I get like 15 of those cannot read property 'user' of undefined messages within a couple seconds

Delete the clearbotmessages option. As it doesn't work

Okay, I will give that a try, thanks