Reputation: 71
I've got this so far:
function dailylot() {
let channel = message.guild.channels.find(channel => channel.name === "general69420")
if (!channel) {
return;
}
channel.send(".")
return;
}
function settimer() {
setTimeout(() => {
settimer()
dailylot()
console.log("Cycle")
}, 5000)
}
while (i < 1) {
console.log("set timer " + i);
settimer()
i++;
}
Doing this works but only for the guild the message is sent in. Even once removing the while
loop so it activates multiple times, it just wants to go to 1 guild only. How can I retrieve the channels of all servers? bot.guilds.channels
isn't a thing.
Upvotes: 0
Views: 807
Reputation: 467
You wold need to iterate over each of the guilds in your bot and get the channels for each of tem, this is the case because different from message
or guild
, guilds
is not a class, meaning it doesn't have properties like guilds.channels
, it is a collection of other guild classes.
This is an example on how to access those channels individually:
client.guilds.forEach(guild => {
guild.channels.forEach(channel => {
// Use the channel for whatever you need
})
})
Upvotes: 1