mirror of
				https://github.com/Mestima/luna.git
				synced 2025-10-29 23:52:35 +00:00 
			
		
		
		
	added 'js' command
This commit is contained in:
		
							
								
								
									
										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; | ||||||
|  |       }); | ||||||
|  |   } | ||||||
|  | }; | ||||||
		Reference in New Issue
	
	Block a user