@@ -3,7 +3,7 @@ import * as Builders from "@discordjs/builders";
33import { setTimeout as sleep } from "node:timers/promises" ;
44import { formatWithOptions } from "node:util" ;
55import { ChatInputCommand } from "#structures" ;
6- import * as utils from "#util" ;
6+ import * as util from "#util" ;
77
88export default new ChatInputCommand ( {
99 async run ( app , interaction , options ) {
@@ -14,21 +14,20 @@ export default new ChatInputCommand({
1414 const depth = options . getInteger ( "depth" ) ?? 1 ;
1515 const useAsync = Boolean ( options . getBoolean ( "async" , false ) ) ;
1616 const embed = new Builders . EmbedBuilder ( )
17- . setTitle ( "__Eval__" )
1817 . setColor ( + process . env . EMBED_COLOR ! )
19- . addFields ( { name : "Input" , value : Builders . codeBlock ( code . slice ( 0 , 1010 ) ) } ) ;
18+ . setDescription ( Builders . codeBlock ( "js" , code . slice ( 0 , 1010 ) ) ) ;
2019 const now = performance . now ( ) ;
2120 let output ;
2221
2322 try {
2423 output = await eval ( useAsync ? `(async () => { ${ code } })()` : code ) ;
2524 } catch ( err : any ) {
26- utils . log ( "Red" , err ) ;
25+ util . log ( "Red" , err ) ;
2726
2827 embed
2928 . setColor ( 16711680 )
3029 . addFields ( {
31- name : `Output • ${ ( performance . now ( ) - now ) . toFixed ( 5 ) } ms` ,
30+ name : ( performance . now ( ) - now ) . toFixed ( 5 ) + "ms" ,
3231 value : Builders . codeBlock ( err )
3332 } ) ;
3433
@@ -42,7 +41,7 @@ export default new ChatInputCommand({
4241 flags : app . ephemeral
4342 } ) ;
4443
45- new utils . Collector ( app , {
44+ new util . Collector ( app , {
4645 filter : int => ( int . member ?? int ) . user ! . id === ( interaction . member ?? interaction ) . user ! . id ,
4746 max : 1 ,
4847 timeout : 60_000
@@ -57,13 +56,13 @@ export default new ChatInputCommand({
5756 }
5857
5958 // Output manipulation
60- output = typeof output === "object"
61- ? "js\n" + formatWithOptions ( { depth } , "%O" , output )
62- : "\n" + String ( output ) ;
59+ const formattedOutput = typeof output === "object"
60+ ? formatWithOptions ( { depth } , "%O" , output )
61+ : String ( output ) ;
6362
6463 embed . addFields ( {
65- name : `Output • ${ ( performance . now ( ) - now ) . toFixed ( 5 ) } ms` ,
66- value : `\`\`\` ${ output . slice ( 0 , 1016 ) } \n\`\`\``
64+ name : ( performance . now ( ) - now ) . toFixed ( 5 ) + "ms • " + util . formatString ( typeof output ) ,
65+ value : Builders . codeBlock ( "js" , formattedOutput . slice ( 0 , 1000 ) )
6766 } ) ;
6867
6968 await app . api . interactions . editReply ( process . env . CLIENT_ID ! , interaction . token , { embeds : [ embed . toJSON ( ) ] } ) ;
0 commit comments