我一直在开发一个不和谐的机器人,我需要一个来自index.js的脚本,但我想知道我是否应该在cmdFunctions.js的底部做bot.login?

index.js
const Discord = require('discord.js');
const bot = new Discord.Client();
const cmdFunctions = require('./cmdFunctions.js');
const config = require("./config.json");
var prefix = '>';
bot.on('ready', msg=>{
console.log('This bot is online');
})
bot.on('message', msg =>{
if (!msg.content.slice(0,1) == " "){
var content = msg.content;
msgArray = content.split(" ");
msgPrefix = msgArray[0].slice(0,1);
msgCMD = msgArray[0].slice(1);
if (msg.author.bot === false && msgPrefix == config.prefix && cmdFunctions[msgCMD]) {
cmdFunctions[msgCMD](content.substring(content.indexOf(' ')+1), msg);
}
}
})
bot.login(config.token);cmdFunctions.js
const Discord = require('discord.js');
const bot = new Discord.Client();
const cmdFunctions = require('./cmdFunctions.js');
const config = require("./config.json");
module.exports = {
reactionRoleGroups: function(vars, msg) {
bot.on("messageReactionAdd", (messageReaction, user) =>{
console.log(":L");
if (true){
RRGM.edit("Thanks!")
}
})
varsSplit = vars.split(config.variableSeperator);
var Emojis = varsSplit[0];
if (Emojis) {
var EmojisSeperated = Emojis.split(",");
var RRGM = msg.channel.send("You are setting up a RR Group") //.send("hello /n :)")
}
}
}这是我的帖子,如果我还需要什么,请告诉我。:)
发布于 2020-08-13 07:50:40
不,不需要。您只需要在主脚本的末尾登录,除非您使用与第二个脚本不同的令牌来初始化一个完全不同的应用程序。
https://stackoverflow.com/questions/63386092
复制相似问题