This repository was archived by the owner on Dec 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheris.js
More file actions
149 lines (142 loc) · 4.91 KB
/
Copy patheris.js
File metadata and controls
149 lines (142 loc) · 4.91 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
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
142
143
144
145
146
147
148
149
const eris = require('eris')
const config = require('./config.json')
const util = require('util')
const client = new eris.CommandClient(config.token, {
autoreconnect: true,
getAllUsers: false,
restMode: true,
defaultImageFormat: 'png'
}, {
defaultHelpCommand: true,
name: 'Library of Code - Eval Bot',
owner: 'Matthew#0008',
prefix: ['@mention ', 'loc eris '],
defaultCommandOptions: {
cooldown: 2000,
cooldownMessage: 'A little too quick there, slow down.'
}
});
client.registerCommand('eval', async (msg, args) => {
const code = args.join(' ');
if (code === 'client.disconnect()') return msg.channel.createMessage('You cannot do that.')
if (code === 'process.exit()') return msg.channel.createMessage('You cannot do that.')
if (code === 'process.kill()') return msg.channel.createMessage('You cannot do that.')
if (code === 'process.abort()') return msg.channel.createMessage('You cannot do that.')
if (code === 'msg.channel.guild.leave()') return msg.channel.createMessage('You cannot do that.')
let evaled;
try {
evaled = await eval(code);
switch (typeof evaled) {
case 'object':
evaled = util.inspect(evaled, {
depth: 0
});
break;
default:
}
} catch (err) {
const errorEmbed = {
title: 'Eris JavaScript Eval',
color: 16711680,
description: `\`\`\`xl\n${err}\`\`\``,
timestamp: new Date(msg.createdAt),
footer: {
text: client.user.username,
icon_url: client.user.avatarURL
}
};
return msg.channel.createMessage({embed: errorEmbed});
}
if (typeof evaled === 'string') {
evaled = evaled.replace(client.token, '[TOKEN]');
}
if (evaled == undefined) {
evaled = 'undefined';
}
if (evaled.length > 1900) {
evaled = 'Response too large to be sent.';
}
const successEmbed = {
title: 'Eris JavaScript Eval',
color: 65280,
description: `\`\`\`js\n${evaled}\`\`\``,
timestamp: new Date(msg.createdAt),
footer: {
text: client.user.username,
icon_url: client.user.avatarURL
}
};
return msg.channel.createMessage({embed: successEmbed});
}, {
'description': 'Evaluates JavaScript code.',
'aliases': ['e'],
'cooldown': 5000,
'hidden': true,
'requirements': {
'roleIDs': ['507377905370660894']
//'userIDs': ['278620217221971968']
}
})
client.registerCommand('info', async (msg, args) => {
msg.channel.sendTyping();
const embed = {
author: {
name: client.user.username,
icon_url: client.user.avatarURL
},
description: 'This is a clone of the [Moonglow](https://github.com/FCCouncil/Moonglow/tree/loc-eval) GitHub branch. It\'s an open eval bot for people to evaluate code with!',
fields: [
{
name: 'Version',
value: '1.0.0',
inline: true
},
{
name: 'Created At',
value: new Date(client.user.createdAt).toLocaleString('en-us'),
inline: true
},
{
name: 'Library',
value: '[Eris](https://github.com/abalabahaha/eris)',
inline: true
},
{
name: 'Language',
value: 'JavaScript & TypeScript',
inline: true
},
{
name: 'Contributors',
value: 'The Phoenix of Phoebus#9935',
inline: false
},
{
name: 'Developers',
value: 'Matthew#0008, CoalSephos#7566, Flatbird#0001',
inline: false
}
],
timestamp: new Date(msg.createdAt),
footer: {
text: client.user.username,
icon_url: client.user.avatarURL
}
};
msg.channel.createMessage({embed: embed});
})
process.on('uncaughtException', (err) => {
//const errorMsg = err.stack.replace(new RegExp(`${__dirname}/`, 'g'), './');
const errorMsg = err.stack;
console.log(`Uncaught Exception Error: ${errorMsg}`);
//Raven.captureException(err);
// Always best practice to let the code crash on uncaught exceptions.
// Because you should be catching them anyway.
process.exit(1);
});
process.on('unhandledRejection', err => {
console.log(`Unhandled Rejection Error: ${err.stack}`);
//client.channels.get('503374059044601872').send(err);
//Raven.captureException(err);
});
client.connect()