1- import { Command , type CommandContext , Declare , Embed , type Message , Options , type WebhookMessage , createStringOption } from "seyfert" ;
1+ import {
2+ Command ,
3+ type CommandContext ,
4+ Declare ,
5+ Embed ,
6+ type Message ,
7+ Options ,
8+ type WebhookMessage ,
9+ createIntegerOption ,
10+ createStringOption ,
11+ } from "seyfert" ;
212import { EmbedColors , Formatter } from "seyfert/lib/common/index.js" ;
313import { StelleOptions } from "#stelle/decorators" ;
414
5- import { Configuration } from "#stelle/data/Configuration.js" ;
615import { getDepth , sliceText } from "#stelle/utils/functions/utils.js" ;
716
817import { DeclareParserConfig , ParserRecommendedConfig , Watch , Yuna } from "yunaforseyfert" ;
9- import { SECRETS_MESSAGES , SECRETS_REGEX } from "#stelle/data/Constants.js" ;
18+ import { SECRETS_MESSAGES } from "#stelle/data/Constants.js" ;
1019import { ms } from "#stelle/utils/TimeFormat.js" ;
1120
21+ const secretsRegex = / \b (?: c l i e n t \. (?: c o n f i g ) | c o n f i g | e n v | p r o c e s s \. (?: e n v | e x i t ) | e v a l | a t o b | b t o a ) \b / ;
22+ const concatRegex = / " .* ?" \s * \+ \s * " .* ?" (?: \s * \+ \s * " .* ?" ) * / ;
23+
1224const options = {
1325 code : createStringOption ( {
1426 description : "Enter some code." ,
1527 required : true ,
1628 } ) ,
29+ depth : createIntegerOption ( {
30+ description : "Enter the depth of the result." ,
31+ min_value : 0 ,
32+ } ) ,
1733} ;
1834
1935@Declare ( {
2036 name : "eval" ,
2137 description : "Eval code with Stelle." ,
2238 aliases : [ "code" ] ,
23- guildId : Configuration . guildIds ,
2439 defaultMemberPermissions : [ "ManageGuild" , "Administrator" ] ,
2540 integrationTypes : [ "GuildInstall" ] ,
2641 contexts : [ "Guild" ] ,
@@ -53,6 +68,7 @@ export default class EvalCommand extends Command {
5368 const { client, options, author, channelId } = ctx ;
5469
5570 const start = Date . now ( ) ;
71+ const depth = options . depth ;
5672
5773 let code : string = options . code ;
5874 let output : string | null = null ;
@@ -71,15 +87,14 @@ export default class EvalCommand extends Command {
7187 } ) ;
7288
7389 try {
74- const concatText = / " .* ?" \s * \+ \s * " .* ?" (?: \s * \+ \s * " .* ?" ) * / ;
75- if ( SECRETS_REGEX . test ( code . toLowerCase ( ) ) || concatText . test ( code . toLowerCase ( ) ) )
90+ if ( secretsRegex . test ( code . toLowerCase ( ) ) || concatRegex . test ( code . toLowerCase ( ) ) )
7691 output = SECRETS_MESSAGES [ Math . floor ( Math . random ( ) * SECRETS_MESSAGES . length ) ] ;
7792 else if ( typeof output !== "string" ) {
7893 if ( / ^ (?: \( ? ) \s * a w a i t \b / . test ( code . toLowerCase ( ) ) ) code = `(async () => ${ code } )()` ;
7994
8095 output = await eval ( code ) ;
8196 typecode = typeof output ;
82- output = getDepth ( output ) . replaceAll ( process . env . TOKEN ! , client . token ) ;
97+ output = getDepth ( output , depth ) . replaceAll ( process . env . TOKEN ! , "π" ) . replace ( process . env . DATABASE_URL ! , "π" ) ;
8398 }
8499
85100 await ctx . editOrReply ( {
0 commit comments