Closed noftaly closed 4 years ago
I can not reproduce the described behavior, be it with or without this exact provided id "490635207125368842"
on v12.2.0.
Can you reproduce this with any ban?
I'm not sure how this specific error can be thrown in this code either.
647 Try to resolve the provided value to a User UserManager#resolveID / BaseManager#resolveID 648 Throw error if none found ("Couldn't resolve the user ID to fetch the ban." in src/errors/Messages.js l.76) 653 ff. Doing the request (throws "DiscordAPIError: Unknown Ban" if not banned)
The fact that you get "UnhandledPromiseRejectionWarning" further suggests that the provided code is not in fact the cause for the error, as you do catch any error that would throw during the #fetchBan call in the provided code. (would also log undefined, since that's the return value of console.error
, which banInfos would resolve to)
Here is one such error log:
DEBUG: Starting
DiscordAPIError: Unknown Ban
at RequestHandler.execute (C:\Users\souji\Documents\projects\djs-testing\v12\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
name: 'DiscordAPIError',
message: 'Unknown Ban',
method: 'get',
path: '/guilds/---snip---/bans/1',
code: 10026,
httpStatus: 404
}
DEBUG: Finishing
undefined
The fact that you get "UnhandledPromiseRejectionWarning" further suggests that the provided code is not in fact the cause for the error, as you do catch any error that would throw during the #fetchBan call in the provided code.
From where does it come then?
I tried with another member, same thing.
I added a try {} catch {} around the line but the error is not caught.
I also tried to add debug messages inside the discordjs module but to be fair I did not understand the code very well... 😂 (in the API calls. My debug message right before the return
inside fetchBan
was called before the error, but after that, I don't know where to put the console.logs... I tried something and it might come from the .get. Now that I've done it seems obvious, but we got the confirmation 😂)
So yeah something's definitely going wrong because as you said I should not get the baninfo if it threw + with my noop catch it should not log the error + my try/catch around it should catch it anyway...
I don't know if all of that comes from my code, because maybe if I delete all my folder and start from something fresh (= deleting all the cache etc) it will work.
It comes from somewhere that you attempt to perform an API operation on GuildMember, such as fetching.
The fetchBan
method has correct error handling, therefore as Souji pointed out this is not where your UnhandledRejection is thrown.
It comes from somewhere that you attempt to perform an API operation on GuildMember, such as fetching. The fetchBan method has correct error handling, therefore as Souji pointed out this is not where your UnhandledRejection is thrown.
How can i know where it comes from then ? Because my humble debugging clearly showed that the error occured at fetchBan... I added a debug in discord.js right before the .get.then() and it appeared before the error, and one in my code right after de .fetchBan and it appeared after the error...
EDIT: The other developper working with me on this bot had the same error with the same code... (yet we have our own client and our own databases etc etc... Just the code is the same as it is sync with github)
If you still believe this to be a failure of the #fetchBan method please move the faulty code into an isolated environment (new bot) and strip away its functionalities until you reached the bare-bones of what's needed to reproduce this behavior (mwe).
If you can still reproduce this after isolating your code please post said example here (it should be in a format where others can just download it, plug their token into the login function and be able to reproduce and verify this bug report). Further please provide the exact steps as manual we can follow to attempt reproduction.
Because my humble debugging clearly showed that the error occured at fetchBan... I added a debug in discord.js right before the .get.then() and it appeared before the error, and one in my code right after de .fetchBan and it appeared after the error...
That's a misconception on your end, as i explained above your debugging showed that the error is not from anything happening in #fetchBan, else you would not get the behavior you show in op (unhandled rejection)
so far you provided
console.log('DEBUG: Starting');
const banInfos = await guild.fetchBan("490635207125368842").catch(console.error);
console.log('DEBUG: Finishing');
console.log(banInfos);
which, if plugged into a fresh bot (without whatever other functionality you have on yours), does not result in the behavior you outline, as i explained in this comment.
If your co-dev runs the same (complete) code, them too experiencing the same issue is expected.
I finally found where this came from, it was indeed another part of the code where i fetched the member. The timing of the debug messages made me think this was coming from the fetchban but it was not... Sorry for bothering you all and thanks for your time :)
Please describe the problem you are having in as much detail as possible: Guild#fetchBan(userId) throws an error even tho it happened successfully...
Include a reproducible code sample here, if possible:
What I get:
Btw I get the same error by "noop-ing" the .catch with
.catch(() => {});
...Further details:
discord.js version: 12.2.0
Node.js version: v14.3.0
Operating system: macOS 10.15.5
Priority this issue should have – please be realistic and elaborate if possible: Medium (I would even say High as my bot is set up to automatically crash when an error occurs, but this might only be my case... And it is set up like this because it runs with pm2 and I don't want it to idle when something occurs but rather crash and restart correctly)
[ ] I have also tested the issue on latest master, commit hash: I have not.
Sorry if this is just me doing something wrong but no one was able to answer on the discord.