This commit is contained in:
Jan 2021-02-18 15:22:32 +01:00
parent 216960f3e2
commit be37e998e5
3 changed files with 57 additions and 11 deletions

52
commands/eval.js Normal file
View file

@ -0,0 +1,52 @@
const Discord = require('discord.js');
const { inspect } = require('util');
const { logger, client } = require('../');
module.exports.meta = {
name: 'eval',
aliases: ['e']
}
/**
* @param {Discord.Message} message
* @param {Array<string>} args
*/
module.exports.run = async (message, args) => {
const ownerID = process.env.OWNER_ID;
if (!ownerID) return message.channel.send('Error: Bot owner is not configured. Set `OWNER_ID` env var.');
if (ownerID != message.author.id) {
logger.warn(`${message.author.tag} ${message.author.id} => Not bot owner`);
return;
}
try {
const exec = args.join(' ');
if (!exec) return message.channel.send('What do you want me to do, dumbass');
eval(
`(async () => {` +
`${exec.replace(/(```\w*\n)|\n```$/g, '')}\n` +
`})()`
)
.then(res => {
if (res == undefined)
message.react('✅')
.catch(() => message.channel.send('```js\nundefined\n```'));
else
message.channel.send(
`\`\`\`js\n${
inspect(res)
.replace(new RegExp(client.token, 'g'), '[Token removed]')
.slice(0, 1989)
}\n\`\`\``
);
})
.catch(e => {
message.channel.send(`\`\`\`js\n${(e && e.name && e.message ? `${e.name}: ${e.message}` : `Error: ${e}`).slice(0, 1989)}\n\`\`\``)
.catch(a => message.channel.send(a));
});
} catch(e) {
message.channel.send(`\`\`\`js\n${(e && e.name && e.message ? `${e.name}: ${e.message}` : `Error: ${e}`).slice(0, 1989)}\n\`\`\``)
.catch(a => message.channel.send(a));
}
}

View file

@ -47,7 +47,7 @@ client.on('message', message => {
)
return;
}
else if (cmd.meta?.epicOnly && !message.member.roles.cache.get('718862546395988078')) {
else if (cmd.meta?.epicOnly && !message.member?.roles.cache.get('718862546395988078')) {
logger.warn(`${message.author.tag} => Refusing to run epic only command`);
message.channel.send(
new Discord.MessageEmbed()

View file

@ -19,7 +19,7 @@ const coinsDB = require('./karma').coins;
/**
* @param {Message} message
*/
module.exports.execute = function(message) {
module.exports.execute = async (message) => {
if (!message.content) return;
if (message.content.length > 280) return randomAward();
@ -38,14 +38,8 @@ module.exports.execute = function(message) {
return;
// Spam a fuckton of awards
message.react('731564182079799306').then(() => {
message.react('719181283393142786').catch().then(() => {
message.react('731192828415443116').catch().then(() => {
message.react('731192829262692372').catch().then(() => {
message.react('731192942080950333').catch().then(() => {
message.react('731508866273247252').catch().then(() => {
message.react('716021350883393566').catch();
})})})})})});
['731564182079799306', '719181283393142786', '731192828415443116', '731192829262692372', '731192942080950333', '731508866273247252', '716021350883393566']
.forEach(async id => await message.react(id));
break;
case 'upvote':
message.react('719181283393142786');
@ -65,7 +59,7 @@ module.exports.execute = function(message) {
})
.catch(error => {
console.error(error);
message.channel.send('Wit.ai error:\n' + error);
message.channel.send(`Wit.ai error:\n\`\`\`js\n${error}\`\`\``);
});
function randomAward(multiplier) {
if (!multiplier) multiplier = 1;