漫游器如何创建其中包含渠道的类别?

时间:2020-07-16 05:26:49

标签: javascript node.js discord bots discord.js

      if(!args[0]) return message.channel.send("Missing Parameter: `guild`")
      if(args[0] === "guild") {
      const loggingChannel = message.guild.channels.cache.find(ch => ch.name === "katsu-member-logs");
      const katsuCategory = "Chika Logs";
      if(!loggingChannel) {
      const channelName = "katsu-member-logs";
          message.guild.channels.create(channelName, { parent: katsuCategory.id, topic: "Katsu Member Logs" }).then(c => {
              const allUsers = message.guild.roles.cache.find(r => r.name === "@everyone")
              c.updateOverwrite(allUsers, {
                  SEND_MESSAGES: false
              })
          });
        } else {
            await message.channel.send("Oops, it looks like `katsu-member-logs` channel already exist in this server");
        }
      }
    }

我有这段代码。创建通道时,它工作正常,但是,未在通道应到达的位置创建文本类别。我不太确定如何解决此问题。 Discord.JS v12.2.0

1 个答案:

答案 0 :(得分:0)

您需要将该语句替换为以下内容:

const katsuCategory = "Chika Logs";

应该是:

const katsuCategory = message.guild.channels.cache.find(c => c.name === 'Chika Logs' && c.type === 'category');

您现在应该可以访问它的ID并使用该ID作为父频道来创建频道:)