-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·50 lines (44 loc) · 1.76 KB
/
index.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
#!/usr/bin/env node
const Discord = require("discord.js");
const bot = new Discord.Client();
var token = require("./token.json");
var config = require("./config.json");
async function getInfectedFunction(message) {
let author = message.author.id;
let member = message.mentions.users.first();
if(!member) return;
let infection = config.infectionRoleID;
if (message.guild.members.cache.get(author).roles.cache.get(infection)) return;
if (message.guild.members.cache.get(member.id).roles.cache.get(infection)) {
let chance = Math.random() * 100;
if (chance <= 100) {
await(message.guild.members.cache.get(author).roles.add(infection));
message.channel.send(`<@${author}> has been infected!`);
};
}
}
async function giveInfectionFunction(message) {
let pingee = message.mentions.users.first();
if(!pingee) return;
let infection = config.infectionRoleID;
if(message.guild.members.cache.get(pingee.id).roles.cache.get(infection)) return;
if(message.member.roles.cache.get(infection)) {
let chance = Math.random() * 100;
if (chance <= 100) {
await(message.guild.members.cache.get(pingee.id).roles.add(infection));
message.channel.send(`<@${pingee.id}> has been infected by <@${message.author.id}>!`);
};
}
}
bot.on("ready", () => {
console.log(`logged in as ${bot.user.tag}`);
console.log(`https://discordapp.com/api/oauth2/authorize?client_id=${bot.user.id}&permissions=0&scope=bot`);
});
bot.on("message", message => {
if (message.channel.type === "dm") return;
if (message.author.type === "bot") return;
giveInfectionFunction(message);
getInfectedFunction(message);
});
bot.on("error", console.error);
bot.login(`${token.token}`);