1
1
import { runInNewContext } from 'vm' ;
2
2
3
- import { Command , Interaction , Structures } from 'detritus-client' ;
3
+ import { Collections , Command , Interaction , Structures } from 'detritus-client' ;
4
4
import { MAX_ATTACHMENT_SIZE } from 'detritus-client/lib/constants' ;
5
5
import { Markup } from 'detritus-client/lib/utils' ;
6
6
7
7
import { utilitiesCodeRun , utilitiesFetchMedia , utilitiesFetchText , utilitiesImagescriptV1 } from '../api' ;
8
- import { CodeLanguages } from '../constants' ;
8
+ import { CodeLanguages , MAX_MEMBERS_SAFE } from '../constants' ;
9
9
10
10
import * as DefaultParameters from './defaultparameters' ;
11
11
import * as Parameters from './parameters' ;
12
12
import {
13
13
bigIntGenerateBetween ,
14
14
bigIntMax ,
15
15
bigIntMin ,
16
+ generateCodeFromLanguage ,
17
+ generateCodeStdin ,
16
18
getCodeLanguage ,
17
19
randomFromArray ,
18
20
randomFromIterator ,
@@ -95,7 +97,7 @@ export const AllowedDiscordProperties = Object.freeze({
95
97
96
98
export enum TagIfComparisons {
97
99
EQUAL = '=' ,
98
- NOT_EQUAL = "!=" ,
100
+ EQUAL_NOT = "!=" ,
99
101
GREATER_THAN = '>' ,
100
102
GREATER_THAN_OR_EQUAL = '>=' ,
101
103
LESS_THAN = '<' ,
@@ -106,7 +108,7 @@ export enum TagIfComparisons {
106
108
107
109
export const TAG_IF_COMPARISONS = [
108
110
TagIfComparisons . EQUAL ,
109
- TagIfComparisons . NOT_EQUAL ,
111
+ TagIfComparisons . EQUAL_NOT ,
110
112
TagIfComparisons . GREATER_THAN ,
111
113
TagIfComparisons . GREATER_THAN_OR_EQUAL ,
112
114
TagIfComparisons . LESS_THAN ,
@@ -485,27 +487,9 @@ const ScriptTags = Object.freeze({
485
487
tag . variables [ PrivateVariables . NETWORK_REQUESTS ] ++ ;
486
488
487
489
if ( arg ) {
488
- let guild : any = context . guild ;
489
- if ( guild ) {
490
- guild = guild . toJSON ( ) ;
491
- guild . members = [ ] ;
492
- guild . presences = [ ] ;
493
- guild . voice_states = [ ] ;
494
- }
495
490
const response = await utilitiesCodeRun ( context , {
496
- code : arg ,
497
- input : JSON . stringify ( {
498
- channel : context . channel ,
499
- channel_id : context . channelId ,
500
- guild,
501
- guild_id : context . guildId ,
502
- member : context . member ,
503
- member_bot : context . me ,
504
- message : ( context instanceof Command . Context ) ? context . message : null ,
505
- user : context . user ,
506
- user_bot : context . client . user ,
507
- variables : tag . variables ,
508
- } ) ,
491
+ code : generateCodeFromLanguage ( language , arg ) ,
492
+ input : generateCodeStdin ( context , tag . variables ) ,
509
493
language,
510
494
} ) ;
511
495
if ( response . error ) {
@@ -913,7 +897,7 @@ const ScriptTags = Object.freeze({
913
897
case TagIfComparisons . EQUAL : {
914
898
compared = values [ 0 ] === values [ 1 ] ;
915
899
} ; break ;
916
- case TagIfComparisons . NOT_EQUAL : {
900
+ case TagIfComparisons . EQUAL_NOT : {
917
901
compared = values [ 0 ] !== values [ 1 ] ;
918
902
} ; break ;
919
903
case TagIfComparisons . GREATER_THAN :
0 commit comments