1
votes

Sorry if bad english! First i run my discord bot and i use the tutorial from "Threebow" Then im in the last part of tutorial i got command !userinfo - show embed but when i lanched !userinfo i got these error in colsole

(node:13056) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ReferenceError: messsage is not defined
(node:13056) [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.

This is my code discord bot code

const botSettings = require("./botsettings.json");
const Discord = require("discord.js");
const prefix = botSettings.prefix;

const bot = new Discord.Client({disableEveryone: true})

bot.on("ready", async () => {
    console.log(`Bot is ready! ${bot.user.username}`);

    try {
        let link = await bot.generateInvite(["ADMINISTRATOR"]);
        console.log(link);
    } catch(e) {
        console.log(e.stack);
    }
});

bot.on("message", async message =>{
    if(message.author.bot) return;
    if(message.channel.type === "dm") return;

    let messageArray = message.content.split(" ");
    let command = messageArray[0];
    let args = messageArray.slice(1);

    if(!command.startsWith(prefix)) return;

    if(command === `${prefix}userinfo`) {
        let embed = new Discord.RichEmbed()
            .setAuthor(message.author.username)
            .setDescription("This is the user info!")
            .setColor("#9B59B6")
            .addField("Full username", `${message.author.name}#${message.author.discriminator}`)
            .addField("ID", message.author.id)
            .addField("Create At", message.author.createAt)

        messsage.channel.sendEmbed(embed);

        return;
    }
});

bot.login(botSettings.token);
4
messsage.channel.sendEmbed(embed) is a promise which throws an error upon rejection, you should catch the rejection . Try, messsage.channel.sendEmbed(embed).catch(err => console.log(err)); - Faisal Umair

4 Answers

4
votes

Okay i get the answer! from Faisal Umair! replace the

messsage.channel.sendEmbed(embed)

to

messsage.channel.sendEmbed(embed).catch(err => console.log(err));
1
votes

Well. Maybe try to read the Errors and actually understand them.

Your Wrote messsage.channel.send(embed);
But u need to write it like message.channel.send(embed);

0
votes

Found your problen. you defined message but then did messsage.channel.send(embed). Change messsage to message. 3 s'.

0
votes

Your code is erroring because in your function message.channel.send, you have message written with 3 s’s. However, it’s good practice to send embed in curly brackets, as RichEmbeds are changed in to Embed JSON before sending Updated line: message.channel.send({embed})