创建带有嵌入的频道

时间:2020-09-26 22:47:43

标签: javascript node.js discord discord.js

我尝试创建一个非常小的售票机器人。

我只希望在响应时打开支持渠道,而别无其他。

这是我正在使用的代码。

  const ember = new Discord.MessageEmbed()
    .setColor('#E40819')
    .setTitle('⚠️SUPPORT')
    .setDescription("Open a Ticket")
    let msgEmbed6 = await message.channel.send(ember)
    await msgEmbed6.react('⚠️')

1 个答案:

答案 0 :(得分:1)

if语句中的代码仅在用户做出反应时才能运行,我不确定“打开支持渠道”是什么意思。

const reaction = msgEmbed6.awaitReactions((reaction, user) => user.id === message.author.id, { max: 1, timeout: TIME_IN_MILLISECONDS });

if (reaction.size > 0) {
    // Creates a new text channel called 'Support'
    const supportChannel = await message.guild.channels.create('Support', { type: 'text' });
    // Stops @everyone from viewing the channel
    await supportChannel.updateOverwrite(message.guild.id, { VIEW_CHANNEL: false });
    // Allows the message author to send messages to the channel
    await supportChannel.updateOverwrite(message.author, { SEND_MESSAGES: true, VIEW_CHANNEL: true });
}