Answer the question
In order to leave comments, you need to log in
How to fix bug with bot.login(token);?
The bot is not starting due to some error.
The code:
const Discord = require('discord.js');
const bot = new Discord.Client();
bot.commands = new Discord.Collection();
const fs = require('fs');
let config = require('./botconfig.json');
let token = config.token;
let prefix = config.prefix;
fs.readdir('./cmds/',(err,files)=>{
if(err) console.log(err);
let jsfiles = files.filter(f => f.split(".").pop() === "js");
if(jsfiles.length <=0) console.log("нет комманд длля загрузки!!")
console.log(`загружено ${jsfiles.length} файлов`);
jsfiles.forEach((f,i) =>{
let props = require(`./cmds/${f}`);
console.log(`4{I+1}/.${F} Загружен!`);
bot.command.set(props.help.name,props);
})
bot.on('ready', () => {
console.log(`бот готов ${bot.user.username}`)
bot.generateInvate([ADMINISTRATOR]).then(link =>{
console.log(link);
});
bot.on('message', msg => {
if (msg.content === 'ping') {
msg.reply('Pong!');
if(Message.author.bot) return;
if(Message.Channel.type == "dm") return;
let user = message.author.username;
let usetid = message.author.id;
let messageArray = message.content.split(" ")
let command = messageArray[0].toLoserCase();
let args = messageArray.slice(1);
if(message.content.startWith(prefix)) return;
let cmd = bot.commands.get(command.slice(prefix.length));
if(cmd) cmd.run(bot,message,args);
};
bot.login(token);
ожидалось "}".ts(1005) [41,18]
Answer the question
In order to leave comments, you need to log in
PHPH!!! It is logical that it does not start. In the same place, the console writes to you IN THE FACE.
logical!!!
bot.on('message', msg => {
if (msg.content === 'ping') {
let cmd = bot.commands.get(command.slice(prefix.length));
if(cmd) cmd.run(bot,message,args);
};
bot.login(token);
bot.on('ready', () => {
//твой код
});
let cmd = bot.commands.get(command.slice(prefix.length));
if(cmd) cmd.run(bot,message,args);
};
bot.login(token);
});
let cmd = bot.commands.get(command.slice(prefix.length));
if(cmd) cmd.run(bot,message,args);
};
});
bot.login(token);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question