He estado haciendo este bot y no tengo ni idea de como solucionar el error
const Discord = require('discord.js');
const client = new Discord.Client();
const token = 'NzQzNDIzNTg3ODQ2OTc5NjI0.XzUdKw.arCHAv4Jwhc3lkA1nvoKxX7_ykU';
const prefix = 'L!';
client.on('ready', () => {
console.log('Luxe listo para funcionar!');
presence();
});
client.on('message', message => {
if (message.author.bot) return;
if (!message.content.startsWith(prefix)) return;
//comandos
const args = message.content
.slice(prefix.lenght)
.trim()
.split(/ +/g);
const command = args.shift().toLowerCase();
if (command == 'luxe') {
const embed = new Discord.MessageEmbed()
message.channel.send('Ese soy yo! ^^');
}
});
client.on('message', message => {
if (message.author.bot) return;
if (!message.content.startsWith(prefix)) return;
//comandos
const args = message.content
.slice(prefix.lenght)
.trim()
.split(/ +/g);
const command = args.shift().toLowerCase();
///embeds/////
if (command == 'help') {
const embed = new Discord.MessageEmbed()
.setTitle('Ayuda de Luxe')
.setColor(0x5900ff)
.setDescription(
'Soy luxe, y aqui puedes encontrar la informacion necesaria para aprender a usarme'
)
.addField(
'Quien soy?',
'Soy un robot capaz de ayudarte en lo que quieras, lee mi estado por si quieres obtener más ayuda :)'
)
.addField(
'Comandos actuales',
'Mis comandos actuales son L!luxe, L!help, L!info y he implementado mi funcion propia de baneo, usa L!Ban y menciona a un usuario para echarle a patadas, aún no estoy completado, pero puedes disfrutar de mis funciones'
);
message.channel.send(embed);
}
});
client.on('message', message => {
if (message.author.bot) return;
if (!message.content.startsWith(prefix)) return;
//comandos
const args = message.content
.slice(prefix.lenght)
.trim()
.split(/ +/g);
const command = args.shift().toLowerCase();
///embeds/////
if (command == 'info') {
const embed = new Discord.MessageEmbed()
.setTitle('Info del servidor')
.setColor(0x5900ff)
.setDescription('Aqui encontrarás algo de información del servidor')
.addField('Nombre del servidor', message.guild.name, true)
.addField('Usuarios', message.guild.memberCount, true);
message.channel.send(embed);
}
});
client.on('message', message => {
if (message.author.bot) return;
if (!message.content.startsWith(prefix)) return;
//comandos
const args = message.content
.slice(prefix.lenght)
.trim()
.split(/ +/g);
const command = args.shift().toLowerCase();
///embeds////
if (command == 'ban') {
let buser = message.mentions.users.first();
let breason = args.join(' ');
if (!buser) return message.channel.send('Menciona a algún usuario!');
if (!breason) return message.channel.send('Dime una razón');
if (!message.member.hasPermission('BAN_MEMBERS'))
return message.channel.send('No tienes permisos suficientes!');
const embed = new Discord.MessageEmbed()
.setThumbnail(buser.avatarURL)
.setColor('RANDOM')
.addField('Usuario Baneado', buser.username)
.addField('ID', buser.id)
.addField('Motivo', breason)
.addField('Moderador', message.author.username);
message.guild.member(buser).ban(breason).reason;
buser.send(embed);
message.channel.send(embed);
}
});
client.login(token);
Este es el log:
PS C:\Users\Jaime\Desktop\BOTS\bot tesla> node .
Luxe listo para funcionar!
(node:8664) UnhandledPromiseRejectionWarning: ReferenceError: presence is not defined
at Client. (C:\Users\Jaime\Desktop\BOTS\bot tesla\index.js:10:3)
at Client.emit (events.js:314:20)
at WebSocketManager.triggerClientReady (C:\Users\Jaime\Desktop\BOTS\bot tesla\node_modules\discord.js\src\client\websocket\WebSocketManager.js:431:17)
at WebSocketManager.checkShardsReady (C:\Users\Jaime\Desktop\BOTS\bot tesla\node_modules\discord.js\src\client\websocket\WebSocketManager.js:415:10)
at WebSocketShard. (C:\Users\Jaime\Desktop\BOTS\bot tesla\node_modules\discord.js\src\client\websocket\WebSocketManager.js:197:14)
at WebSocketShard.emit (events.js:314:20)
at WebSocketShard.checkReady (C:\Users\Jaime\Desktop\BOTS\bot tesla\node_modules\discord.js\src\client\websocket\WebSocketShard.js:475:12)
at WebSocketShard.onPacket (C:\Users\Jaime\Desktop\BOTS\bot tesla\node_modules\discord.js\src\client\websocket\WebSocketShard.js:447:16)
at WebSocketShard.onMessage (C:\Users\Jaime\Desktop\BOTS\bot tesla\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\Jaime\Desktop\BOTS\bot tesla\node_modules\ws\lib\event-target.js:132:16)
(node:8664) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8664) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.