Reputation:
I am attempting to delete channels on my discord server using my bot and this is the code:
if (message.content === 'tanbu')
message.guild.channels.forEach(channel => channel.delete())
.then(console.log)
.catch(console.error);
the error is :
TypeError: message.guild.channels.forEach is not a function
What do I do?
Upvotes: 0
Views: 3274
Reputation: 11
I believe that that is for raiding and self bots witch is against discord TOS i defiently would think w
Upvotes: 1
Reputation: 208
Maybe you should think twice before doing such actions. Because this leads to violation of the Discord tos. And it even spams the discord api. which could lead you to a api ban to a particular endpoint or globally sometimes. Even if the library has ability to slow down it , you could still easily bypass it. The ideal solution here is using a sleep function , and not using a forEach
loop, maybe a for loop would do better.
Still this is not recommended doing , if your intention is to nuke servers.
Upvotes: 1
Reputation: 6625
This would've worked in Discord JS V11, but not in V12.
This is what you're looking for:
message.guild.channels.cache.forEach(channel => channel.delete());
https://discord.js.org/#/docs/main/stable/class/GuildChannelManager?scrollTo=cache
Upvotes: 1