Sapphire - Imagine a framework
Sapphire - Imagine a framework

discordjs-support

Root Question Message

AlphaMinedime
AlphaMinedime12/30/2022
My Welcome Message And Auto Role Doesn't Work

const Discord = require('discord.js')
const client = new Discord.Client()

client.on('guildMemberAdd', (member) => {
    const welcomeChannelId = {
        '1058088182861791282': '1058088182861791284'
    }
    const guild = client.guilds.cache.get("1058088182861791282")
    member.guild.channels.cache.get(welcomeChannelId[member.guild.id]).send(`:wave: Welcome ${m} to **${guild}**! We are now at **${guild.memberCount} members**. Thank you for joining!`)
    const MemberRoleAdd = member.guild.roles.cache.get('1058187823703916604')
    member.roles.add(MemberRoleAdd)
})
24
2412/30/2022
"does't work" what do you mean by this @1040838414121050213?
Krish
Krish12/30/2022
need more details
AlphaMinedime
AlphaMinedime12/30/2022
It does not show any error, or it does not send the message in the dizzy server.
24
2412/30/2022
Have you tried to debug?
24
2412/30/2022
There's a lot going on. Try to hardcode values in places and see if it works
AlphaMinedime
AlphaMinedime12/30/2022
No, sorry, idk how 😅
24
2412/30/2022
I highly suggest using log statements or using the debugger built into visual studio code and looking for places that your code isn't doing what you think it's doing
24
2412/30/2022
I can tell you that you're using .cache.get which means that you're probably just not finding the channel or guild because it was never added to the cache. You should fetch the items you need
AlphaMinedime
AlphaMinedime12/30/2022
Ok, I will. Thank you. Please keep this open just in case please.
24
2412/30/2022
I don't control if this is open or not. Please make sure to mark the answer when you verify it is resolved
AlphaMinedime
AlphaMinedime12/30/2022
Ok!
AlphaMinedime
AlphaMinedime12/30/2022
Ok, can someone help me with the console.error?
AlphaMinedime
AlphaMinedime12/30/2022
it does not log anything
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy