mirror of
https://github.com/Mestima/luna.git
synced 2025-05-05 21:50:15 +00:00
added 'js' command
This commit is contained in:
parent
2e823228af
commit
b33e253ffc
36
src/commands/js/index.js
Normal file
36
src/commands/js/index.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { SlashCommandBuilder } from 'discord.js';
|
||||||
|
import { node } from 'compile-run';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName('js')
|
||||||
|
.setDescription('Execute JavaScript code.')
|
||||||
|
.addStringOption((option) => {
|
||||||
|
option.setName('code')
|
||||||
|
.setDescription('code to execute')
|
||||||
|
.setRequired(true);
|
||||||
|
return option;
|
||||||
|
})
|
||||||
|
.addBooleanOption((option) => {
|
||||||
|
option.setName('hide')
|
||||||
|
.setDescription('hide your code')
|
||||||
|
.setRequired(false);
|
||||||
|
return option;
|
||||||
|
}),
|
||||||
|
async execute(interaction, api) {
|
||||||
|
const code = interaction.options.getString('code');
|
||||||
|
const hide = interaction.options.getBoolean('hide');
|
||||||
|
node.runSource(code)
|
||||||
|
.then(res => {
|
||||||
|
let payload = '```js\n' + res.stdout + '\n```';
|
||||||
|
if (!hide) {
|
||||||
|
payload = '```js\n' + code + '\n```' + payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
interaction.reply(payload);
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
throw e;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user