This repository has been archived on 2024-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
discord.js-rr-bot/Src/Commands/SlashCommands/Dev/Exec.js
2022-06-18 23:28:38 -04:00

36 lines
No EOL
1.3 KiB
JavaScript

const { exec } = require("child_process")
module.exports = {
name: 'exec',
ownerOnly: true,
options: [{
name: 'command',
description: 'The command to execute',
required: true,
type: 'STRING'
}],
run: async (client, interaction, container) => {
const row = new container.Discord.MessageActionRow()
.addComponents(
new container.Discord.MessageButton()
.setCustomId('evalbtn')
.setLabel('Delete Output')
.setStyle('DANGER')
)
let lola = interaction.options.getString('command')
if (!lola) return interaction.reply("Please provide what to execute in the terminal!")
exec(`${lola}`, (error, stdout) => {
let response = (error || stdout)
if (error) {
interaction.reply({
content:`\`\`\`js\n${error.message}\n\`\`\``,
components: [row]
})
} else {
interaction.reply({
content:`\`\`\`js\n${response}\n\`\`\``,
components: [row]
})
}
})
}
}