BlueGit

blue-star danique-bot

Files

danique-bot / node_modules / discord.io / examples / auto-role.js

auto-role.js

Import template
timfa Tim · pushed by timfa · 4 years ago
c788ad20 History
auto-role.js 759 B Download Raw
1var Discord = require('discord.io');
2var drole = ""; /* roleid to be applied when someone joins the server */
3var serverid = ""; /* your server id */
4var bot = new Discord.Client({
5 autorun: true, /* If false, you need to connect to the server using bot.connect(); */
6 token: "" /* your discordapp token */
7});
8
9bot.on('ready', function() {
10 console.log("Successfully connected: " + bot.username + " - (" + bot.id + ")");
11});
12
13bot.on('guildMemberAdd', function(callback) { /* Event called when someone joins the server */
14 if(callback.guild_id == serverid)
15 bot.addToRole({"serverID":serverid,"userID":callback.id,"roleID":drole},function(err,response) {
16 if (err) console.error(err); /* Failed to apply role */
17 /* some code */
18 });
19 });