discord.js,我是否需要2个bot.logins?

问题描述

我一直在研究一款不和谐的机器人,我需要index.js中的脚本,但是我想知道我是否也应该在bot.login的底部执行cmdFunctions.js吗?

explorer

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 :)")
        }
    }
}

这是我的帖子,所以告诉我是否还有其他需要。 :)

解决方法

不,不需要。除非您要使用与第二个脚本不同的令牌初始化一个完全不同的应用程序,否则您只需要在主脚本的末尾登录即可。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...