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.
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`)