删除频道的困惑

时间:2019-01-15 17:49:10

标签: javascript node.js discord.js

我在尝试让Discord机器人删除频道(特别是人声频道)时遇到问题。我对于应该如何删除用户选择的特定频道感到困惑

我的代码:

if (command === "p-close") {
  const m = await message.channel.send("Preparing to close the party..");

  const guild = message.guild;
  let [name] = args; //Get the channel name
  channel.delete('Deleting the party')
    .then(deleted => console.log(`Deleted ${deleted.name} to make room for new channels`))
    .catch(console.error);

  m.edit(`The party ${name} has been closed.`);
}

这似乎对我不起作用,所以这就是为什么我来这里。感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

Try using it like this:

const channel = message.guild.channels.find(channel => channel.name === name)