Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
Welcome System in Discord.js dosent work & no error

So I was making welcome system on my discord bot and encountered the problem where my code dosent work (dosent respond) but there is no error.

So i made command to set welcome channel --It Works
I also setted Schema (i using mongoDB) where i will save guildId, ChannelId & RoleID. --Work

Then i have file: welcomer.js which actually need to send the message when user join, but it dosent, i also dont have any errors in console:

SetChannel.js:

        async execute(interaction, client, message) {
        try {

            if(!interaction.member.permissions.has('ADMINISTRATOR')) return interaction.reply('You are not allowed to use this command')
            const channel = interaction.options.getChannel('channel')
            const role = interaction.options.getRole('role')

            Schema.findOne({Guild: interaction.guild.id}, async(err, data) => {
                if(data) {
                    data.Channel = channel.id
                    data.Role = role.id 
                    data.save()
                } else {
                    new  Schema({
                        Guild: interaction.guild.id,
                        Channel: interaction.channel.id,
                    }).save()
                }
            })
            interaction.reply(`${channel} has been set as welcome channel
${role} will be given to the new members when they join the server.`)
            //.then(console.log)
            .catch(console.error)
        }
        catch(err) {
            console.log(err)
        }
    }
}

welcomeSchema.js:

    const mongoose = require('mongoose')

const Schema = new mongoose.Schema({
    Guild: String,
    Channel: String,
    Role: String,
})

module.exports = mongoose.model('welcome-channel', Schema)

welcomer.js:

//const client  = require('../index')
const Schema = require('../database-schema/welcomeSchema')
const { MessageEmbed, Client, Intents, Discord } = require('discord.js')

        const allIntents = new Intents(32767);
        const client = new Client({intents: [ allIntents ]})


        client.on('guildMemberAdd', async (member, guild) => {
                Schema.findOne({ Guild: member.guild.id }, async (e, data) => {
                    if (!data) {
                        return console.log('No channel to send the message!')
                    }
                        

                    const channel = member.guild.channels.cache.get(data.Channel)
                    let role = member.guild.roles.cache.get(data.Role)

                    const embed = new MessageEmbed()
                        .setTitle('Welcome!')
                        .setColor('BLURPLE')
                        .setDescription(`Welcome to the server, ${member.tag}! I hope you will have a great time here.`)
                        .setTimestamp()

                    channel.send({ embeds: [embed] })


                    member.role.add()
                })
            })
        
           
        
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!