I used a code to make the welcome message work on my server, I could choose any text channel so that the message would be sent as soon as a new member joined the server, but for a few days this code stopped working without any problem at the bot terminal.
I've done several tests even with other welcome codes but none of them work.
this is the code where the welcome message goes, it searches the database for the channel that was defined through a command
bot.on("guildMemberAdd", (member) => {
let chx = db.fetch(`welchannel_${member.guild.id}`);
if(chx === null) {
return;
}
let wembed = new MessageEmbed()
.setAuthor(member.user.username, member.user.avatarURL())
.setColor("#ff2050")
.setThumbnail(member.user.avatarURL())
.setDescription(`We are very happy to have you in our server`);
bot.channels.cache.get(chx).send(wembed)
})
this is the command that defines the channel where the welcome message will be sent.
in the database the information is entered correctly.
const db = require("../../database");
const Discord = require("discord.js");
const { DiscordAPIError, MessageEmbed } = require("discord.js");
module.exports = {
name: "set",
description: "Set the prefix of the guild!",
category: "config",
aliases: "bemvindos",
run: async (bot, message, args) => {
let channel = message.mentions.channels.first()
if(!channel) {
return message.channel.send("Please Mention the channel first")
}
//Now we gonna use quick.db
db.set(`welchannel_${message.guild.id}`, channel.id)
message.channel.send(`Welcome Channel is seted as ${channel}`)
}
}
the new member enters the server and the bot does not send the message on the defined channel or at least one error message on the terminal.