-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
89 lines (68 loc) · 2.69 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
79
80
81
82
83
84
85
86
87
88
89
//Inicializando as variáveis de ambiente (use process.env.NOME_DA_VAR)
require('dotenv').config();
const Discord = require('discord.js');
const discordToken = process.env.DISCORD_TOKEN;
const client = new Discord.Client({ shards: 'auto' });
const utilFunctions = require('./utilFunctions');
const db = require('./database');
const { commandHandler } = require('./commands/commandHandler');
client.on('guildCreate', async guild => {
let guildDB = await db.query(`SELECT * FROM KBGuild WHERE KBGGuildID = ${guild.id}`);
if(guildDB==undefined) {
await db.query(`INSERT INTO KBGuild (KBGGUildID, KBGName) VALUES (${guild.id}, '${guild.name}')`);
} else {
let guildName = guildDB.KBGName;
if(guildName!=guild.name)
await db.query(`UPDATE KBGuild SET KBGName = '${guild.name}' WHERE KBGGuildID = ${guild.id}`);
}
})
client.on('ready', () => {
console.log(`Ready!`);
client.user.setActivity("com seu cú | -help");
});
client.on('message', async message => {
if(message.author.bot) return;
let xingamentos = [
'VAI SE FUDE OTÁRIO',
'VEM AQUI DÁ UMA SUGADA NA MINHA ROLA',
'Tá mandando mensagem por que? Tá achando que aqui é Twitter?',
'~Tua mãe tá solteira?',
];
let chanceXingamento = await utilFunctions.randomInt(1, 3000);
if(chanceXingamento<=10)
message.reply(xingamentos[await utilFunctions.randomInt(0, xingamentos.length)]);
let guildDB = await db.query(`SELECT * FROM KBGuild WHERE KBGGuildID = ${message.guild.id}`);
let guildName = guildDB.KBGName;
if(guildName!=message.guild.name)
await db.query(`UPDATE KBGuild SET KBGName = '${message.guild.name}' WHERE KBGGuildID = ${message.guild.id}`);
let prefix = guildDB.KBGPrefix;
if(message.content.startsWith(prefix)) {
commandHandler(message, prefix);
}
});
client.on('voiceStateUpdate', async (oldState, newState) => {
// const audioController = require('./commands/audio/audioController');
// const serverQueue = audioController.serverQueue.get(oldState.guild.id);
// if(serverQueue==undefined)
// return;
// if(oldState.channelID!==newState.channelID)
// serverQueue.voiceChannel = newState.guild.channels.cache.get(newState.channelID);
// let message = [];
// message.guild = [];
// message.guild.id = newState.guild.id;
// if(!oldState.serverMute&&newState.serverMute) {
// serverQueue.textChannel.send("Mut0u porqu3 g4y? :s");
// audioController.pause(message, false);
// } else {
// audioController.resume(message, false);
// }
});
client.login(discordToken);
exports.getAllGuilds = getAllGuilds;
/**
* @description Function that returns an array with all guilds connected
* @returns Array containing all guilds
*/
async function getAllGuilds() {
return client.guilds.cache;
}