Currently, I am developing an event-bot to use in multiple Discord groups. Here is the code snippet I have been working on:
if (command === "init")
{
message.channel.send("BunnBot starting...");
var interval = setInterval (function () {
message.channel.send("123");
}, 30 * 1000);
}
The issue I'm facing is that this command only works within one group, requiring me to use the init command separately in each group. How can I modify my code to make the Bot send messages to every group?
Edit: I made some changes to the code as follows:
client.on("ready", () => {
console.log('Logged in as BunnyBot');
setInterval (function () {
client.guilds.forEach(() => {
let defaultChannel = "";
client.guilds.forEach((channel) => {
if(channel.type == "text" && defaultChannel == "") {
if(channel.permissionsFor(guild.me).has("SEND_MESSAGES")) {
defaultChannel = channel;
}
}
})
message.defaultChannel.send("Message here");
console.log("Sending Messages");
})
}, 1 * 1000);
})
However, I encountered a problem where I received an error stating that send is not a function.