-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
78 lines (58 loc) · 2.75 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const Discord = require("discord.js");
const client = new Discord.Client();
const db = require("quick.db");
client.on('ready', () => {
const text = `
______________________________
Logged in as: ${client.user.tag}
Servers: ${client.guilds.size}
Users: ${client.users.size}
______________________________
`;
console.log(text);
});
client.on('guildMemberAdd', async member => {
const betterstatbot = new db.table('betterstatbot');
let sguildid = await betterstatbot.fetch(`Stats_${member.guild.id}`, { target: '.guildid' })
let tusers = await betterstatbot.fetch(`Stats_${member.guild.id}`, { target: '.totusers' })
let membs = await betterstatbot.fetch(`Stats_${member.guild.id}`, { target: '.membcount' })
let bots = await betterstatbot.fetch(`Stats_${member.guild.id}`, { target: '.botcount' })
const totalsize = member.guild.memberCount;
const botsize = member.guild.members.filter(m => m.user.bot).size;
const humansize = totalsize - botsize;
if(member.guild.id === sguildid) {
member.guild.channels.get(tusers).setName("Total Users : " + member.guild.memberCount);
member.guild.channels.get(membs).setName("Human Users : " + humansize);
member.guild.channels.get(bots).setName("Bot Users : " + member.guild.members.filter(m => m.user.bot).size);
}
});
client.on('guildMemberRemove', async member => {
const betterstatbot = new db.table('betterstatbot');
let sguildid = await betterstatbot.fetch(`Stats_${member.guild.id}`, { target: '.guildid' })
let tusers = await betterstatbot.fetch(`Stats_${member.guild.id}`, { target: '.totusers' })
let membs = await betterstatbot.fetch(`Stats_${member.guild.id}`, { target: '.membcount' })
let bots = await betterstatbot.fetch(`Stats_${member.guild.id}`, { target: '.botcount' })
const totalsize = member.guild.memberCount;
const botsize = member.guild.members.filter(m => m.user.bot).size;
const humansize = totalsize - botsize;
if(member.guild.id === sguildid) {
member.guild.channels.get(tusers).setName("Total Users : " + member.guild.memberCount);
member.guild.channels.get(membs).setName("Human Users : " + humansize);
member.guild.channels.get(bots).setName("Bot Users : " + member.guild.members.filter(m => m.user.bot).size);
}
});
client.on("message", async (message) => {
if (message.author.bot) return;
if (message.channel.type === "dm") return;
let prefix = "?"
let args = message.content.slice(prefix.length).trim().split(" ");
let cmd = args.shift().toLowerCase();
if (!message.content.startsWith(prefix)) return;
try {
let commandFile = require(`./commands/${cmd}.js`);
commandFile.run(client, message, args);
} catch (e) {
console.log(e);
}
});
client.login("Your Bot's Token Goes Here");