-
Notifications
You must be signed in to change notification settings - Fork 10
/
codare.js
143 lines (126 loc) · 4.09 KB
/
codare.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
const Discord = require("discord.js");
const client = new Discord.Client();
client.conf = {
"token": "TOKEN ",
"pref": "!",
"own": "idniz",
"oynuyor": "Oynuyor",
"durum": "dnd"// durumu
}
client.on("message", message => {
let client = message.client;
if (message.author.bot) return;
if (!message.content.startsWith(client.conf.pref)) return;
let command = message.content.split(" ")[0].slice(client.conf.pref.length);
let params = message.content.split(" ").slice(1);
let perms = client.yetkiler(message);
let cmd;
if (client.commands.has(command)) {
cmd = client.commands.get(command);
} else if (client.aliases.has(command)) {
cmd = client.commands.get(client.aliases.get(command));
}
if (cmd) {
if (perms < cmd.conf.permLevel) return;
cmd.run(client, message, params, perms);
}
})
client.on("ready", () => {
console.log(`Bütün komutlar yüklendi, bot çalıştırılıyor...`);
console.log(`${client.user.username} ismi ile Discord hesabı aktifleştirildi!`);
let mob;
if(client.conf.durum == "online") mob = "Çevrimiçi";
if(client.conf.durum == "offline") mob = "Çevrimdışı";
if(client.conf.durum == "idle") mob = "Boşta";
if(client.conf.durum == "dnd") mob = "Rahatsız Etmeyin";
console.log(`Durum ayarlandı: ${mob}!`)
client.user.setPresence({ activity: { name: client.conf.oynuyor,type:2 }, status: client.conf.durum })
console.log(`Oynuyor ayarlandı!`);
})
const db = require("quick.db");
const chalk = require("chalk");
const fs = require("fs");
const moment = require("moment");
var prefix = client.conf.prefix;
const log = message => {
console.log(`${message}`);
};
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
fs.readdir("./komutlar/", (err, files) => {
if (err) console.error(err);
log(`${files.length} adet komut yüklenmeye hazır. Başlatılıyor...`);
files.forEach(f => {
let props = require(`./komutlar/${f}`);
log(`Komut yükleniyor: ${props.help.name}'.`);
client.commands.set(props.help.name, props);
props.conf.aliases.forEach(alias => {
client.aliases.set(alias, props.help.name);
});
});
});
client.reload = command => {
return new Promise((resolve, reject) => {
try {
delete require.cache[require.resolve(`./komutlar/${command}`)];
let cmd = require(`./komutlar/${command}`);
client.commands.delete(command);
client.aliases.forEach((cmd, alias) => {
if (cmd === command) client.aliases.delete(alias);
});
client.commands.set(command, cmd);
cmd.conf.aliases.forEach(alias => {
client.aliases.set(alias, cmd.help.name);
});
resolve();
} catch (e) {
reject(e);
}
});
};
client.load = command => {
return new Promise((resolve, reject) => {
try {
let cmd = require(`./komutlar/${command}`);
client.commands.set(command, cmd);
cmd.conf.aliases.forEach(alias => {
client.aliases.set(alias, cmd.help.name);
});
resolve();
} catch (e) {
reject(e);
}
});
};
client.unload = command => {
return new Promise((resolve, reject) => {
try {
delete require.cache[require.resolve(`./komutlar/${command}`)];
let cmd = require(`./komutlar/${command}`);
client.commands.delete(command);
client.aliases.forEach((cmd, alias) => {
if (cmd === command) client.aliases.delete(alias);
});
resolve();
} catch (e) {
reject(e);
}
});
};
client.yetkiler = message => {
if (!message.guild) {
return;
}
let permlvl = 0;
if(message.member.hasPermission("MANAGE_MESSAGES")) permlvl = 1;
if(message.member.hasPermission("MANAGE_ROLES")) permlvl = 2;
if(message.member.hasPermission("MANAGE_CHANNELS")) permlvl = 3;
if(message.member.hasPermission("KICK_MEMBERS")) permlvl = 4;
if(message.member.hasPermission("BAN_MEMBERS")) permlvl = 5;
if(message.member.hasPermission("ADMINISTRATOR")) permlvl = 6;
if(message.author.id === message.guild.ownerID) permlvl = 7;
if(message.author.id === client.conf.own) permlvl = 8;
return permlvl;
};
///DOKUNMA
client.login(client.conf.token)