Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

127
Vistas
Pass the bot configuration file so that it is accessible globally from Client

I'm wanting to pass my bot's configuration file (config.json) into the bot client so I can get for example, the bot's owner ID instead of specifying it in each command that I want only the bot owner to access, or the embed footer text, example:

    async execute(client, message, args, footerTxt) {
        if (message.author.id == BotOwnerId) {

I want to be able to just have it be

       async execute(client, message, args){
                if (message.author.id == client.config.ownerID) {

I have tried running it through the command execute

    try {
        await client.commands.get(command).execute(client, message, args, footerTxt, config);
    } catch (error) {

which resulted in

TypeError: Cannot read properties of undefined (reading 'ownerID')
at Object.execute
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

config.json

{
   "ownerID": "XXXXXXXXXXX",
   "someOtherStuff": [],
   "someMoreStuff": { "id": 1, "name": "Test" }
}

index (assuming config.json is in the same folder)

const config = require('./config.json')

await client.commands.get(command).execute(client, message, args, footerTxt, config);

cmd:

if (message.author.id == config.ownerID) {

Why not simply requiring the config file in index and passing it through the args to the command? Or require it in the commands? As you wish but it should do the trick

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda