嗨,我想创建一个 Discord.JS-Commando 命令,如果您选择一个频道,机器人会删除它在那里拥有的 webhook,如果它被命名Marker
,并且如果它检测到那里是否没有它拥有的 webhook,Marker
它只是命名为return message.channel.send("Hey! There's no webhook I own in this channel!")
机器人删除了一个 webhook,即使它没有成功,而且它不在我提到的频道中。我该如何解决?
在谷歌上搜索,什么都没有。除了 discord.js 文档之外,没有任何关于删除 webhook 的内容。
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}`);
});
我希望机器人知道如何删除它在提到的频道中创建的 webhook,但机器人不知道要删除哪个 webhook。