Open Exp1123 opened 7 years ago
Looks like you might be using discord.js, not discord.io.
oh, I been writing a mix of them, thought there weren't much difference since their both based off JavaScript. Where do I went wrong? I've been using discord.io to run my code
Both being JS doesn't mean the same code will work with both libraries.
Few things I notice:
serverNewMember
is not an event name, discord.io uses guildMemberAdd
The callback for this event handler only has one argument, an object called member
Try console logging it to view the structure.
get
is not a method of the bot.servers
object, nor of channelID
which is not even an object.
I'm not sure what the purpose of your if
statement is.
This is the wrong place to ask for help with snippets and code, the purpose of git issues is to report issues affecting the Lib iitself, the code you are trying to use is also for the wrong Lib, serverNewMember
is an event in d.js and guildMemberAdd
is an event in discord.io, rip i just got ninja'd by vegeta
Discord has already a function to do that, go to your server settings. There would be a Join messages switch there.
How would I make a bot do send a welcome message when a user first joins the discord server?
I tired this code, it doesn't seem to run, it compiled, but no actions when someone new joins the server. Also user.mention(), I am not sure if that is the proper way to @mention someone via javascript for discord.
bot.on('serverNewMember',function (user, userID, channelID, message, evt){ if(user === bot.servers.get('id',"SERVERID")) bot.sendMessage(channelID.get('name','general'),"Welcome to my Server "+user.mention()+"!") })