-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
83 lines (69 loc) · 2.81 KB
/
index.js
File metadata and controls
83 lines (69 loc) · 2.81 KB
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
const Discord = require('discord.js');
const client = new Discord.Client({ partials: ["MESSAGE", "USER", "REACTION"] });
const { token, prefix, logo, hex_color, community_name, role_access_id, discord_logs_channel_id, database_host, database_user, database_password, database_base} = require('./config.json');
var mysql = require('mysql')
const bot = new Discord.Client();
var con = mysql.createConnection({
host: database_host,
user: database_user,
password: database_password,
database: database_base
})
con.connect(function(err) {
if (err) throw err;
console.log("MySQL połączone!")
})
function addWhitelist(steamhex) {
var sql = `INSERT INTO whitelist SET identifier = '${steamhex}'`;
con.query(sql, function (result){
if (result) { console.log(result) }
console.log("WL ADD - " + steamhex)
});
}
function sendSuccsess(action, admin, chnl, steamhex) {
const chnlsucc = new Discord.MessageEmbed()
.setColor(hex_color)
.setAuthor(`${community_name}`, logo)
.setTitle('Akcja wykonana pomyślnie!')
.setDescription(`${admin.toString()}, Dodano **${steamhex}** do whitelist'y.`)
chnl.send(chnlsucc);
client.channels.fetch(discord_logs_channel_id)
.then(channel => {
const SuccEmbed = new Discord.MessageEmbed()
.setAuthor(`${community_name} - BotLog`, logo)
.setTitle(`Aktualizacja ${action}`)
.setDescription(`${admin.toString()}, Dodał **${steamhex}** do whitelist'y.`)
.setColor(hex_color);
channel.send(SuccEmbed);
})
}
client.on('ready', () => {
console.log(community_name + "'s Update Player BOT has been loaded.");
client.user.setActivity("ExperienceRP", {
type: "WATCHING",
name: "!pomoc"
});
});
client.on('message', async message => {
if (message.author.bot) return;
if (message.content.indexOf(prefix) !== 0) return;
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if (command == "wl") {
if (!message.member.roles.cache.has(role_access_id)) return;
if (args[0] == undefined)return message.reply('Wprowadz prawidłowy hex! ```steam:hex```');
if (!args[0].includes("steam:"))return message.reply('Wprowadz prawidłowy hex! ```steam:hex```');
addWhitelist(args[0])
sendSuccsess('wl', message.author, message.channel, args[0])
}
if(command == "pomoc") {
if (!message.member.roles.cache.has(role_access_id)) return;
const sendusage = new Discord.MessageEmbed()
.setColor(hex_color)
.setAuthor(community_name + " - WhiteList", logo)
.addFields(
{ name: 'Komenda - Dodaj do whitelist', value: '!wl steam:``hex``', inline: true })
message.channel.send(sendusage);
}
})
client.login(token);