Toby Royal
Toby Royal

Reputation: 3

Confusion on deleting channels

I'm having issues with trying to get my Discord bot to delete channels (specifically vocal ones). I'm confused on how I should actually do the deletion of a specific channel chosen by the user

My code:

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.`);
}

This doesn't seem to be working for me, and so that is why I've come here. Help is appreciated!

Upvotes: 0

Views: 464

Answers (1)

PLASMA chicken
PLASMA chicken

Reputation: 2785

Try using it like this:

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

Upvotes: 1

Related Questions