Deleting all channels in a server

Coding picture Coding · Jul 6, 2018 · Viewed 17.4k times · Source

I'm making a bot that auto-sets up a server, and I was wondering how to delete all channels and categories in a server.

Answer

Rodrigo Soriano picture Rodrigo Soriano · Jul 6, 2018

You can run a loop for every single channel in the server

(Categories are considered as channels too)

//This goes in Client.on('ready', ...);
var server = Client.guilds.get('Your servers ID'); //Check Discord's Help For it
for (var i = 0; i < server.channels.array().length; i++) {
    server.channels.array()[i].delete();
}

This way all your channels and categories will get deleted everytime your bot runs. You can move this code inside a command to delete all the channels with a command instead.