So I want to get every ID from the servers my bot is on. In the best way please in a list so I could get one ID after another because I need them for my prefix system. I tried a lot of designs but it didn't work right.
So I want to get every ID from the servers my bot is on. In the best way please in a list so I could get one ID after another because I need them for my prefix system. I tried a lot of designs but it didn't work right.
You can use Collection#map to map Client.guilds.cache (GuildManager#cache) by ID.
(not supported anymore)
const Discord = require("discord.js");
const client = new Discord.Client();
client.on("ready", () => {
const Guilds = client.guilds.cache.map(guild => guild.id);
console.log(Guilds);
});
client.login(process.env.DISCORD_ACCESS_TOKEN)
const Discord = require("discord.js");
const client = new Discord.Client({
intents: ["GUILDS"],
});
client.on("ready", () => {
const Guilds = client.guilds.cache.map(guild => guild.id);
console.log(Guilds);
});
client.login(process.env.DISCORD_ACCESS_TOKEN);