Discord.js 机器人设置在一台服务器上更改时会在所有服务器上更改 运行 它在 repl.it

Discord.js Bot settings when changed on one server changes on all of them running it on repl.it

您好,上面的问题其实并不多,我只需要知道如何将一台服务器上的设置与另一台服务器上的设置分开。 这是我目前正在使用的代码!

client.on('message', (msg) => {
if (msg.content == `${prefix}setup`) {
    msg.channel.send('To set the prefix use !prefix set (the prefix)');
    msg.channel.send('To set the code prefix use !prefix code (the prefix preferably your yt name)');
    msg.channel.send('Make sure to set the channel for early code release/access use !early set (id of the channel)');
  } else if (msg.content.startsWith(`${prefix}prefix set`)) {
    prefix = msg.content.replace(`${prefix}prefix set`, '').trim()
    console.log(prefix)
    msg.channel.send('Prefix Changed!')
  } else if (msg.content.startsWith(`${prefix}prefix code`)) {
    name = msg.content.replace(`${prefix}prefix code`, '').trim()
    console.log(name)
    client.channels.cache.get(early).send(`Prefix set to ${name}`)
    code = `New code is ${name}${Math.floor(Math.random() * 101)}`
    client.channels.cache.get(early).send(`${code}`);
  } else if (msg.content.startsWith(`${prefix}early set`)) {
    early = msg.content.replace(`${prefix}early set`, '').trim()
    console.log(early)
    msg.channel.send('Early Channel Changed!')
  } else if (msg.content == `${prefix}new code`) {
    code = `code is ${name}${Math.floor(Math.random() * 101)}`
    msg.channel.send(`New ${code}`)
  }
});

您需要一个数据库来进行单独的服务器设置。值得庆幸的是,这很容易做到。您可以使用 discord-prefix.


Discord 前缀

Discord Prefix 是一个简单的 Node.js 模块,可让您有效地管理 discord 机器人的自定义前缀

安装

npm i discord-prefix

Github

RedLukeBug/discord-prefix


希望对您有所帮助!