I'm trying to add a Global Variable (server
) that contains my guild's ID, then I could use, for example: const channel_NAME = server.channels.cache.get('MY CHANNEL ID');
in the top of the code to define all my channels, instead of: member.guild.roles.cache.get('MY ROLE ID');
in every function.
I did it, but this error is returning to me:
const channel_boi_salve = server.channels.cache.get('MY CHANNEL ID');
TypeError: Cannot read property 'channels' of undefined
My code is:
const Discord = require('discord.js');
const bot = new Discord.Client();
const config = require('./config.json');
const fs = require('fs');
// Guild ID
const server = bot.guilds.cache.get("MY GUILD ID");
// Channels (channel_NAME)
const channel_boi_salve = server.channels.cache.get('MY CHANNEL ID');
I'm new to JavaScript so I would appreciate it if someone could explain in detail how to do it.