forked from BlaCoiso/Casper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.js
117 lines (115 loc) · 6.3 KB
/
core.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
// Module Docs___________________________
// | Name: Core
// | Type: CASPER_MODULE
// | Function: Core Casper Commands
// |_____________________________________
module.exports = {
handles(event) {
return event == "message";
},
commands: [
{
name: "eval",
description: "Evaluates code",
perms: "dev",
allowDM: true,
run(message, args) {
if (!args.defaultConfig.getConfig().testVersion) return { text: "This command isn't available in release versions." };
let functionToEval = args.params.join(" ");
console.log("User " + message.author.username + "#" + message.author.discriminator + " used eval: " + functionToEval);
try {
var result = eval(functionToEval);
if (result && String(result).toLowerCase().includes(message.client.token.toLowerCase())) result = "Contains bot's token, censored.";
return { text: "```js\nInput:\n" + functionToEval + "\n\nOutput:\n" + String(result) + "```" };
} catch (err) {
return { text: "```js\nInput:\n" + functionToEval + "\n\nError:\n" + err.message + "```" };
}
}
},
{
name: "reload",
description: "Reloads modules",
perms: "dev",
allowDM: true,
run(message, args) {
try {
args.moduleHandler.reloadModules();
return { text: "Reloaded all modules :thumbsup:", reply: true };
} catch (e) {
args.errLogger(`**${e.name}** while reloading modules: ${e.message}`);
console.error(`${e.name} while reloading modules:\n ${e.stack}`)
return { text: "Failed to reload modules. Please check logs for details." };
}
}
},
{
name: "invite",
description: "Gives the bot's invite link.",
allowDM: true,
aliases: ["addbot", "invitebot"],
run(msg, args) {
let invite = msg.client.generateInvite(268823574).then(i=>args.asyncCallback({ text: `**Invite ${msg.client.user.username} to your server!** ${i}` }));
}
},
{
name: "stats",
description: "Shows the bot's statistics and information.",
allowDM: true,
aliases: ["info", "botstats", "botinfo"],
run(msg, args) {
let devServer = msg.client.guilds.get(args.defaultConfig.getConfig().dev_server);
let devRole = devServer.roles.get(args.defaultConfig.getConfig().dev_role);
let devs = devRole.members.map(m=>m.user.username + "#" + m.user.discriminator);
let stats = new args.embed()
.setColor(15113758)
.setAuthor(msg.client.user.username + " Statistics and Information", msg.client.user.avatarURL)
.addField("Prefix", args.prefix == args.defaultConfig.getConfig().prefix ?
args.prefix : `${args.prefix} (Default: **${args.defaultConfig.getConfig().prefix}**)`, true)
.addField("Library", `Discord.js ${args.Discord.version}`, true)
.addField("Node.js Version", process.version, true)
.addField("Memory Usage", Math.floor(process.memoryUsage().rss / 10485.76) / 100 + " MB", true)
.addField("Guilds", msg.client.guilds.size.toLocaleString(), true)
.addField("Users", msg.client.users.size.toLocaleString(), true)
.addField("Test Instance", args.defaultConfig.getConfig().testVersion ? "Yes" : "No", true)
.addField("Events Handled", args.eventCount + " events", true)
.addField("Developed by:", devs.join(", "), true)
.setThumbnail(msg.client.user.avatarURL)
.setFooter(`Bot Uptime: ${args.utils.getTime(process.uptime())}`);
return { text: "No text fallback available for this command.", embed: stats };
}
},
{
name: "command",
description: "Lists command details.",
allowDM: true,
aliases: ["cmd", "cmdshow"],
run(msg, args) {
if (args.params && args.params[0] && args.params[0] != "") {
let command = args.moduleHandler.findCommand(args.params[0]);
if (command) {
let cmdPerms = (command.perms ? (Array.isArray(command.perms) ? (command.perms.length == 0 ? "None" : command.perms.join(", ")) : command.perms) : "None");
let cmdDMs = command.allowDM ? "Yes" : "No";
let cmdReqPerms = command.noPermsMessage ? "Yes" : "No";
let cmdAliases = (command.aliases ? (Array.isArray(command.aliases) ? (command.aliases.length == 0 ? "None" : command.aliases.join(", ")) : command.aliases) : "None");
let cmdReqArgs = command.requiresArgs ? "Yes" : "No";
let embed = new args.embed()
.setTitle(command.name)
.setDescription(command.description)
.addField("Permissions required", cmdPerms)
.addField("Works on DMs", cmdDMs)
.addField("Requires args", cmdReqArgs)
.addField("Message when no permissions", cmdReqPerms)
.addField("Command aliases", cmdAliases)
.setColor(15113758);
let output = `**Command** ${command.name}:\n **Description**: ${command.description}\n **Permissions Required**: ${cmdPerms}\n **Works on DMs**: ${cmdDMs}\n **Requires Args**: ${cmdReqArgs}\n **Message when no permissions**: ${cmdReqPerms}\n **Aliases**: ${cmdAliases}`;
return { text: output, embed: embed };
} else {
return { text: "Command wasn't found." };
}
} else {
return { text: `\`${args.prefix + args.command}\`: ${this.description}` };
}
}
}
]
}