Discord.js 在用户对消息做出反应时创建一个频道

时间:2020-12-21 16:12:29

标签: node.js discord discord.js

有人可以帮助我吗,我如何获得下面的代码来创建一个频道,所有用户都用相同的表情符号做出反应?

我正在努力使所有对相同战斗表情符号做出反应的用户都将被放入同一个频道,然后我将创建多个嵌入信息。但由于某种原因,我很笨,我不知道该怎么做。

抱歉,如果这很简单,但我是编码新手,因此感谢您提供任何帮助,我希望你们都有一个美好的圣诞节。

Client.on("messageReactionAdd", async (reaction, user, message) => {
  if (reaction.message.partial) await reaction.message.fetch();

  if (user.Client) return;
  if (!reaction.message.guild) return;

  if (reaction.emoji.name === "?") {
    let member = await reaction.message.guild.members.cache.get(user.id);
    console.log(user);
  }
});

1 个答案:

答案 0 :(得分:0)

首先,您将知道如何创建文本频道。

<guild object>.channels.create('Text', {
    type: 'text',
        permissionOverwrites: [{
            id: <guild object>.id,
            allow: ['VIEW_CHANNEL'],
        }]
});

根据反应创建通道很容易。请参阅下面的示例。

const Discord = require('discord.js'); //Define Discord
const client = new Discord.Client(); //Define client

client.on("messageReactionAdd", async (reaction, user, message) => { //Add an event listener
  if (reaction.message.partial) await reaction.message.fetch();

  if (user.id === client.user.id) return; //If the reaction was from the bot, return
  if (!reaction.message.guild) return; //If the reaction was not in a guild

  if (reaction.emoji.name === "?") {
    let guild = reaction.message.guild
    guild.channels.create('channelName', { //Creating the channel
        type: 'text', //Make sure the channel is type is text
        permissionOverwrites: [ //Set overwrites
            {
                id: guild.id,
                allow: ['VIEW_CHANNEL'],
            }]
        })
  }
});