How to send a message on all channels of a server?

I was wondering how can I make my bot send a message on all channels of a server that I am using to test, so I tried using a “forEach (channel => {
channel.send(test)});” but it doesn’t work! How can I fix it?

I don’t think this is a correct setup, I might however be completely wrong though.
The forEach() function is something you can use on arrays, to correctly use it, I suggest something like this:

var channels = //however you intend to get your channels array

  function(channel, index) {
    // other per-channnel logic

Within this loop, channel is your usual channel object and the index is the number that indicates where in the array this channel was. (Unsure if this is zero-based.)

Hope this helps!

@YatoBot @TsjipTsjip,

Mass-sending message(s) to all the servers/guilds or channels, in your case, is not allowed or considered API spam. In the end, you may end up getting banned/blacklisted from the API, so refrain from doing that.


I did not know this, my apologies. Not too familiar with discord bots etc.
You learn every day!

1 Like