discord.js how to get all guilds
client.on("ready", () => {
const Guilds = client.guilds.cache.map(guild => guild.id);
console.log(Guilds);
});
discord.js how to get all guilds
client.on("ready", () => {
const Guilds = client.guilds.cache.map(guild => guild.id);
console.log(Guilds);
});
discord.js how to send a message to all guilds
if (command === "sendguildmessages") {
if (message.author.id === "231956829159161856") {
try {
let toSay = "messageToSend"
this.client.guilds.map((guild) => {
let found = 0
guild.channels.map((c) => {
if (found === 0) {
if (c.type === "text") {
if (c.permissionsFor(this.client.user).has("VIEW_CHANNEL") === true) {
if (c.permissionsFor(this.client.user).has("SEND_MESSAGES") === true) {
c.send(toSay);
found = 1;
}
}
}
}
});
});
}
catch (err) {
console.log("Could not send message to a (few) guild(s)!");
}
} else {
message.reply("You cant do that!")
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us