izy521 / discord.io

A small, single-file library for creating DiscordApp clients from Node.js or the browser
https://discord.gg/0MvHMfHcTKVVmIGP
MIT License
535 stars 154 forks source link

Welcome message for user who is first time joining Server #195

Open Exp1123 opened 7 years ago

Exp1123 commented 7 years ago

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()+"!") })

vegeta897 commented 7 years ago

Looks like you might be using discord.js, not discord.io.

Exp1123 commented 7 years ago

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

vegeta897 commented 7 years ago

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.

https://izy521.gitbooks.io/discord-io/content/

Elesoterik commented 7 years ago

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

memetrollsXD commented 6 years ago

Discord has already a function to do that, go to your server settings. There would be a Join messages switch there.