【问题标题】:Delete a channel with a reaction删除有反应的频道
【发布时间】:2019-07-07 21:02:16
【问题描述】:

我需要帮助,我正在寻找一种方法来删除机器人通过“

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

如果你有机会知道如何使用 discord.js 删除语音频道。

提前感谢您! 真诚的

ticket.js

https://pastebin.com/rpsbPMNT

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

【问题讨论】:

    标签: node.js discord discord.js


    【解决方案1】:

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

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

    我没有尝试此代码,但我认为它必须有效。

    【讨论】:

    • 你好,谢谢你的帮助,我把你告诉我的,我替换了表情符号,但它仍然不起作用,我没有错误。我希望它删除在ticket.js中嵌入“embedParent”的频道,这就是为什么我不明白这一点:message.author.send(embedCloseTicket).then((msg) => {跨度>
    • 嘿,把你的不和谐标签发给我可以直接帮助你,一旦完成,我显然会在这里发布答案;)
    猜你喜欢
    • 2021-02-27
    • 1970-01-01
    • 2021-04-21
    • 2020-10-11
    • 2020-10-15
    • 2021-07-31
    • 2019-03-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多