MihaiT
MihaiT

Reputation: 1

Welcome message when the discord.js bot joins

I changed the version from discord.js v12 to v13 and my bot join message doesn't work anymore.

    const { MessageEmbed, WebhookClient } = require("discord.js");
    const { channels } = require("../../app");
    const { prefix, color } = require("../../botconfig/config.json");

    module.exports = async (bot) => {

        bot.on('guildCreate', (guild) => {

            let channelToSendTo;

            guild.channels.forEach(channel => {
                if (channel.type === 'text' && !channelToSendTo && channel.permissionsFor(guild.me).has('SEND_MESSAGES')) channelToSendTo = channel;
            });

            if(!channelToSendTo) return;

            let newGuildEmbed = new MessageEmbed()
                .setColor(color)
                .setTitle(`<:Ela_E:888341177571639297> Thank you for adding me!`)
                .addField(`Premium`, `[Buy](https://elabot.top/premium)`, true)
                .addField(`Website`, `[Website Page](https://elabot.top)`, true)
                .addField(`Have questions?`, `[Join the support server](https://elabot.top/support)`, true)
            channelToSendTo.send(newGuildEmbed)

        })
        
    }

Error:

(node:15080) DeprecationWarning: The message event is deprecated. Use messageCreate instead (Use node --trace-deprecation ... to show where the warning was created)

Upvotes: 0

Views: 524

Answers (1)

Christoph Bl&#252;m
Christoph Bl&#252;m

Reputation: 975

In V13 sending embeds has changed. Change this line accordingly:

channelToSendTo.send(newGuildEmbed) //V12
channelToSendTo.send({embeds: [newGuildEmbed]}) //V13

Also, as it says in your error: The client.on('message') is deprecate. This has been changed to client.on('messageCreate')

If you bump into any new errors, please check the docs or the update instductions from V12 to V13

Upvotes: 1

Related Questions