forked from ChiefWoof/Updated-Leaderboard-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwoof.js
81 lines (76 loc) · 4.15 KB
/
woof.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
const settings = require("./libraries/settings.json");
const private = require("./libraries/private.json");
const emotes = require("./libraries/emotes.json");
const commands = require("./commands.js");
const woof = require("./libraries/extensions.js");
const Discord = require("discord.js");
const client = new Discord.Client();
client.login(settings.beta && !(settings.forceMainLogin) ? private.tokens.beta : private.tokens.main);
client.on(`message`, msg => {
msg = {
raw: msg,
guildName: msg.guild.name,
guildID: msg.guild.id,
channelName: msg.channel.name,
channelID: msg.channel.id,
authorTag: msg.author.tag,
authorID: msg.author.id,
content: typeof msg.content === "string" ? msg.content : "",
args: [],
prefix: null,
page: 0,
localPage: 0,
localStat: 0,
level: 0,
command: 0,
data: {
guild: woof.cleanPropertyGuilds(woof.propertyTranslate(settings.properties, require("./storedData/guilds.json")[msg.guild.id], 2)),
user: woof.cleanPropertyUsers(woof.propertyTranslate(settings.properties, require("./storedData/users.json")[msg.author.id], 2)),
},
};
msg.prefix = settings.prefixes.map(prefix => {return `${prefix}${settings.beta ? settings.betaPrefix.toString() : ``}`}).find(prefix => msg.content.toLowerCase().startsWith(`${prefix.toLowerCase()}`));
msg.level = isNaN(Number(msg.data.user.level)) ? 0 : Number(msg.data.user.level);
if (!(msg.prefix === undefined)){
msg.content = msg.content.slice(msg.prefix.length, msg.content.length);
msg.content = msg.content.startsWith(" ") ? msg.content.slice(1, msg.content.length) : msg.content;
msg.args = msg.content.split(" ").filter(item => typeof item === "string" ? item.length > 0 : false);
if (msg.args.length > 0){
msg.command = commands.commands.find(cmd => cmd.commands.find(callers => callers.toLowerCase() === msg.args[0].toLowerCase()));
};
};
if (!(msg.raw.author.bot)){
if (typeof msg.command === "object" && (typeof msg.command === "object" ? msg.command.useable : false)){
if (msg.data.guild.channelBots.length === 0 || msg.data.guild.channelBots.some(item => item === msg.channelID)){
if (typeof msg.command.execute === "function" && typeof msg.command === "object"){
if (msg.level >= msg.command.level){
msg.command.execute(client, msg);
}else{
msg.raw.channel.send(`${woof.emote(emotes.ul.error)} **The permission levels on this command prevent you from using it**`)
};
};
}else if (msg.data.guild.channelBots.length > 0){
msg.raw.channel.send(`${woof.emote(emotes.ul.error)} **I do not have permission to use commands here**`);
};
}else if (Number(msg.data.guild.channelRequest) > 0 && msg.channelID === msg.data.guild.channelRequest && typeof msg.content.length > 0){
let commandRequest = commands.commands.find(cmd => cmd.commands.find(callers => callers.toLowerCase() === "request"));
if (typeof commandRequest === "object"){
if (typeof commandRequest.execute === "function"){
commandRequest.execute(client, msg);
};
};
}else if (msg.data.guild.channelCountings.some(item => item === msg.channelID)){
if (!(Number(msg.raw.content) > 0 && Math.floor(Number(msg.raw.content)) === Number(msg.raw.content))){
setTimeout(function(){msg.raw.delete().catch(err => {});}, 1250);
};
}else{
require("./refreshes.js").map(item => {
if (item.useable && typeof item.execute === "function"){
if (item.lastUsed === undefined || Date.now()-Number(item.lastUsed) >= item.cooldown){
item.lastUsed = Date.now();
item.execute(client, msg);
};
};
});
};
};
});