Hi I want to make a Discord.JS-Commando command where if you select a channel, the bot removes a webhook it owns there and if it's named Marker
and if it detects if there's no webhook there that it owns named Marker
it just return message.channel.send("Hey! There's no webhook I own in this channel!")
The bot deletes a webhook even though it didn't make it, and it's not in the channel I mention. How do I fix this?
Searching it up on Google, there was nothing. There wasn't anything on deleting webhooks except discord.js docs.
const hooks1 = await message.guild.fetchWebhooks();
await hooks1.forEach(async webhook => {
if (!watchChannel.id == webhook.channelID) return
if (!webhook.owner.id == `595840576386236437`) return
if (!webhook.name == `Marker`) return message.channel.send(`**${message.author.username}**, Nothing was found. You or someone else may have renamed the webhook. Please delete the webhook manually. Sorry for the inconvenience`);
else
message.channel.send(`Deleted successfully.`).then(msg => {message.delete(4000)}).catch(error => console.log(error))
webhook.delete(`Requested per ${message.author.username}#${message.author.discriminator}`);
});
I expect the bot to know how to delete the webhook that it made, in a mentioned channel, but the bot doesn't know what webhook to delete.