-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbot.js
56 lines (45 loc) · 1.99 KB
/
bot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const Discord = require('discord.js');
const client = new Discord.Client();
const embed = new Discord.MessageEmbed;
client.login('INSERT TOEKN');
client.on('ready', readyDiscord);
function readyDiscord () {
console.log('Ready');
client.user.setActivity(`Protecting ${client.guilds.cache.size} servers`, {
type: "STREAMING",
url: "https://www.twitch.tv/m_ett"
});
client.on('message', gotMessage);
const bot = new Discord.Client();
function gotMessage(msg) {};
client.on('presenceUpdate', (oldMember, newMember) => {
const guild = newMember.guild;
member = newMember;
if (newMember.user.bot) return;
activityLength = newMember.member.presence.activities.length;
//check to see if the user has an activities, and if so, how many
if (activityLength >0 ){
console.log("member has " + activityLength + " activities");
for (let i = 0; i < activityLength; i++) {
//Debugging messages to the log
console.log("Activity in position " + i + " is " + newMember.member.presence.activities[i].name.toLowerCase());
//console.log("now in lower case " + newMember.member.presence.activities[0].name.toLowerCase());
//If you want to ban players of any other game than LOL, changer where it says league of legends to any other lowercase name of a game
if (newMember.member.presence.activities[i].name.toLowerCase() == "league of legends") { // Started playing.
console.log(`<a:banned:942166115373678602> ${newMember.user.tag} has been banned for playing LOL <a:banned:942166115373678602>`);
try{
guild.members.ban(`${newMember.user.id}`, {reason: 'Playing League Of Legends'}).catch((err) => {
console.error(err);
var x = err.message;});
break;
}
catch(err){
}
}
}
} else {
console.log("member has no activities");
}
});
}
client.login('INSERT TOKEN');