dev command shit

master
Kit Kasune 3 years ago
parent e2f743a4a6
commit 9665851c2a
  1. 22
      commands/dev/eval.js
  2. 38
      commands/dev/execute.js
  3. 21
      commands/dev/reload.js

@ -16,14 +16,24 @@ module.exports = {
},
execute(message, msg, args, cmd, prefix, mention, client) {
try {
let timer = new Date().getTime();
if (!client.developers.includes(message.author.id)) {return message.channel.send("Sorry, but I've got trust issues, so only me devs can go commanding me around like that.");};
if (!args.length) return message.channel.send(`Syntax: \`${prefix}eval <code>\``);
if (!args.length) return message.channel.send(`Syntax: \`${prefix}eval <code>\``);
if (!args.length) {return message.reply("Please specify a bio!");}
let args2 = msg.startsWith(prefix)
? message.content.slice(prefix.length).trim().split(/ +/g)
: msg.startsWith('<@!')
? message.content.slice(4 + client.user.id.length).trim().split(/ +/g)
: message.content.slice(3 + client.user.id.length).trim().split(/ +/g);
args2.shift(); args2.shift();
let options = new TagFilter([new Tag(['s', 'silent', 'nr', 'noreply'], 'silent', 'toggle')]).test(args[0]);
if (options.silent) {args.shift();}
let options = new TagFilter([new Tag(['s', 'silent', 'nr', 'noreply'], 'silent', 'toggle')]).test(args2[0]);
if (options.silent) {args2.shift();}
if (!args.length) {return message.channel.send("Silly goose, if you want me to do something, you have to tell me what!");}
const result = new Promise((resolve) => resolve(eval(args.join(' '))));
const result = new Promise((resolve) => resolve(eval(args2.join(' '))));
return result.then((output) => {
if (typeof output !== 'string') {
output = require('util').inspect(output, {depth: 0});
@ -36,12 +46,12 @@ module.exports = {
.setTitle('Client Evaluation')
.setDescription(`\`\`\`js\n${output}\n\`\`\``)
.setColor('328ba8')
.setFooter(`Luno`, client.user.avatarURL())
.setFooter(`Luno | Evaluated in ${new Date().getTime() - timer}ms`, client.user.avatarURL())
.setTimestamp());
}).catch(error => {return message.channel.send(`Error: \`${error}\`.`);});
} catch (error) {
let date = new Date; date = date.toString().slice(date.toString().search(":") - 2, date.toString().search(":") + 6);
console.error(`\n${chalk.red('[ERROR]')} >> ${chalk.yellow(`At [${date}] | Occurred while trying to run n?eval`)}`, error);
console.error(`\n${chalk.red('[ERROR]')} >> ${chalk.yellow(`At [${date}] | Occurred while trying to run l.eval`)}`, error);
return message.channel.send(`Error: \`${error}\`.`);
}
},

@ -0,0 +1,38 @@
const Discord = require('discord.js');
const cp = require("child_process");
module.exports = {
name: "Execute",
aliases: ['exec'],
meta: {
category: 'Developer',
description: "Execute a console command",
syntax: '`Execute <command>`',
extra: null
},
help: "Dev only! Executes a console command",
async execute(message, msg, args, cmd, prefix, mention, client) {
if (!client.developers.includes(message.author.id)) {return message.channel.send("You must be a developer to do this!");}
if (!args.length) {return message.channel.send(`Syntax: \`${prefix}execute <command>\``);}
return cp.exec(args.join(" "), function(error, stdout, stderr) {
if (error) {
return message.channel.send(new Discord.MessageEmbed()
.setTitle("Error")
.setDescription(`\`\`\`${error}\`\`\``)
.setColor("ff446a")
.setFooter("Luno", client.user.avatarURL())
.setTimestamp()
);
}
return message.channel.send(new Discord.MessageEmbed()
.setTitle("Execution Successful")
.setDescription(`\`\`\`${stdout}\`\`\``)
.setColor("328ba8")
.setFooter("Luno", client.user.avatarURL())
.setTimestamp()
);
});
}
};

@ -21,6 +21,7 @@ module.exports = {
},
async execute(message, msg, args, cmd, prefix, mention, client) {
if (!args.length) {
let timer = new Date().getTime();
if (!client.developers.includes(message.author.id) && message.author.id !== "480535078150340609") {return message.channel.send("You must be a Luno developer in order to do this!");}
let commands = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
@ -66,7 +67,7 @@ module.exports = {
console.log(`\n${chalk.gray('[INFO]')} >> ${chalk.hex('ff4fd0')(`Client refresh successful`)}\n`);
return message.channel.send("Done!")
return message.channel.send(`Done! Reloaded ${commands.length} commands, ${eventFilter.length} events, and ${responses.length} responses in ${new Date().getTime() - timer}ms.`);
}
if (['l', 'log', 'ns', 'nosilent', 'notsilent'].includes(args[0].toLowerCase())) {
['commands', 'aliases'].forEach(x => client[x] = new Discord.Collection());
@ -74,6 +75,24 @@ module.exports = {
['command', 'event', 'response'].forEach(x => require(`./${x}`)(client));
return message.channel.send("Done!");
}
if (['c', 'cmd', 'command'].includes(args[0].toLowerCase())) {
let timer = new Date().getTime();
if (!args[1]) {return message.channel.send("Oi there you headass! You have to actually tell me what command to reload!");}
let tc = args[1].toLowerCase();
let lf = client.commands.get(tc) || client.commands.get(client.aliases.get(tc));
lf = lf ? lf.name : tc;
let res;
fs.readdirSync(`./commands`).forEach(x => {
if (!x.includes('.')) {fs.readdirSync(`./commands/${x}`).forEach(y => {if (`${lf}.js` === y) {res = `../../commands/${x}/${y}`;}});}
else {if (x === `${lf}.js`) {res = `../../commands/${x}`;}}
});
if (!res) {return message.channel.send("I can't reload that command as I can't find file!");}
if (require.resolve(res) in require.cache) {delete require.cache[require.resolve(res)];}
client.commands.set(lf, require(res));
return message.channel.send(`Reloaded command \`${lf}\` in ${new Date().getTime() - timer}ms`);
}
else {return message.channel.send("Oi! 'log' is the only valid arg to use. Use no args if you want a cleaner console output instead.");}
}
};
Loading…
Cancel
Save