module.exports = {
name: 'listguilds',
description: 'lists the bots guilds',
execute(message, args, client) {
const Guilds = client.guilds.cache.map(guild => guild.id);
console.log(Guilds);
}}
Im trying to fetch all the ID's of all of the guilds that my bot is in but i keep getting this error
TypeError: Cannot read property 'guilds' of undefined
at Object.execute (C:\Users\User\Desktop\botname\commands\listguilds.js:6:31)
at Client.<anonymous> (C:\Users\User\Desktop\botname\index.js:96:11)
at Client.emit (node:events:365:28)
at MessageCreateAction.handle (C:\Users\User\Desktop\botname\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\User\Desktop\botname\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\User\Desktop\botname\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\User\Desktop\botname\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\User\Desktop\botname\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\User\Desktop\botname\node_modules\ws\lib\event-target.js:132:16)