Check if user is banned

I've checked online etc but can't find it I'm trying to make an unban command but when the user isn't banned and it's ran, it crashes the bot, so I'm trying to make it so it checks if the user is banned, however, I can't find out where to do that. i tried this:
const user = interaction.options.getUser('user')
const guild = client.guilds.cache.get(guildId);

if (await guild.bans.fetch(user))
const user = interaction.options.getUser('user')
const guild = client.guilds.cache.get(guildId);

if (await guild.bans.fetch(user))
but that didn't work, saying DiscordAPIError[10026]: Unknown Ban
2 Replies
d.js toolkit
d.js toolkit9mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Bradley
BradleyOP9mo ago
oops used wrong one i swear i was in the correct one before
Want results from more Discord servers?
Add your server