问题描述
我一直在研究一款不和谐的机器人,我需要index.js
中的脚本,但是我想知道我是否也应该在bot.login
的底部执行cmdFunctions.js
吗?
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 :)")
}
}
}
这是我的帖子,所以告诉我是否还有其他需要。 :)
解决方法
不,不需要。除非您要使用与第二个脚本不同的令牌初始化一个完全不同的应用程序,否则您只需要在主脚本的末尾登录即可。