node.js - 删除有反应的频道
问题描述
我需要帮助,我正在寻找一种方法来删除机器人通过“
我在下面向您展示我的代码。
如果您有任何机会知道如何使用 discord.js 删除语音频道。
先感谢您!真挚地
票务.js
关闭.js
const discord = require("discord.js");
const botconfig = require("../botconfig.json");
module.exports.run = async (bot, message, args) => {
// Id van category van tickets.
const categoryId = botconfig.ticketcategory;
// Als bericht in ticket kanaal is dan verwijder kanaal ander zend bericht
if (message.channel.parentID == categoryId) {
message.channel.delete();
} else {
message.channel.send("Please do this command in a ticket channel.");
}
var embedCloseTicket = new discord.RichEmbed()
.setTitle("Hello, " + message.channel.name)
.setDescription("Your ticket is marked as **complete**. Do you want to make a new one then do !ticket")
.setFooter("Ticket closed!");
message.author.send(embedCloseTicket);
}
module.exports.help = {
name: "close",
aliases: ["ticketclose", "ticketsupportclose"]
}
解决方案
您需要创建一个反应收集器。
//your code...
message.author.send(embedCloseTicket).then((msg) => {
msg.react("the emoji")
}).then(r => {
const filter = (reaction, user) => reaction.emoji.name === "emoji" &&
user.id === message.author.id;
//create the collector
const collectorForU = msg.createReactionCollector(filter, {time: 1000/*time
in ms*/});
collectorForU.on("collect", r => {
msg.channel.delete()
})
})
我没有尝试此代码,但我认为它必须有效。