删除有反应的频道

时间:2019-02-13 22:05:10

标签: node.js discord discord.js

我需要帮助,我正在寻找一种方法,可以通过“

我在下面向您展示我的代码。

如果有机会,您知道如何使用discord.js删除语音通道。

先谢谢您! 真诚的

ticket.js

https://pastebin.com/rpsbPMNT

close.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"]
}

1 个答案:

答案 0 :(得分:0)

您需要创建一个反应收集器。

//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()      
})
})

我没有尝试过这段代码,但是我认为它必须可以工作。