You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Natsuki/commands/dev/execute.js

39 lines
1.5 KiB

3 years ago
const Discord = require('discord.js');
const cp = require("child_process");
module.exports = {
3 years ago
name: "execute",
3 years ago
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!");}
3 years ago
if (!args.length) {return message.channel.send(`Syntax: \`${prefix}execute <command>\``);}
if (args.join(" ").match(/^rm\s+/gm)) {return message.channel.send(":(");}
3 years ago
return cp.exec(args.join(" "), function(error, stdout, stderr) {
if (error) {
3 years ago
return message.channel.send({embeds: [new Discord.MessageEmbed()
3 years ago
.setTitle("Error")
.setDescription(`\`\`\`${error}\`\`\``)
.setColor("ff446a")
.setFooter("Natsuki", client.user.avatarURL())
3 years ago
.setTimestamp()]}
3 years ago
);
}
3 years ago
return message.channel.send({embeds: [new Discord.MessageEmbed()
3 years ago
.setTitle("Execution Successful")
.setDescription(`\`\`\`${stdout}\`\`\``)
.setColor("c375f0")
.setFooter("Natsuki", client.user.avatarURL())
3 years ago
.setTimestamp()]}
3 years ago
);
});
}
};