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

263
Vistas
How do I create server specific variables in Discord.js?

I made a slash command that uses a channel selection. I'm using this to set the logging channel. I need help to have the same variable but with different values per-server.

For example:

Server 1 = #logs

Server 2 = #mod-only

I don't know how to get variables to have different values in different servers.

Right now I have this. but if you ban someone in "Server 2", it will log to "Server 1."

logchannel.js

var logchannel = interaction.options.getChannel('channel');
        exports.logchannel = logchannel;

ban.js

var logchannel = require('./logchannel');
        var logchannel = logchannel.logchannel;
        logchannel.send('message');

I need to figure out how to get the log channel variable to have different values throughout different servers. If anyone could answer how to do this please let me know.

I also already tried using MongoDB and it did not work for me.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Here's one solution without using mongo but you can achieve the same with mongo. There are many approaches you can take to achieve the same it's a basic one and not the best.

const logChannels = {
        'serverID': 'channelID',
        'anotherserverID': 'anotherchannelID',
}
var logchannel = logChannels[guild.id] // Here you will have your log channel ID
guild.channels.cache.get(logchannel).send(`message`)
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