Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

271
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda