[英]discord.js and whether I need 2 bot.logins?
I have been working on a discord bot and I require a script from index.js
but I am wondering if I should do bot.login
at the bottom of cmdFunctions.js
too?我一直在研究 discord 机器人,我需要index.js
的脚本,但我想知道我是否也应该在cmdFunctions.js
的底部做bot.login
?
index.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 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 :)")
}
}
}
This is my post so tell me if I need anything else.这是我的帖子,如果我还需要什么,请告诉我。 :) :)
Nope, no need to.不,没必要。 You only need to login at the end of the main script, unless you're initializing an entirely different application with a different token from the second script.您只需要在主脚本结束时登录,除非您使用与第二个脚本不同的令牌初始化一个完全不同的应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.