11const { GuildMemberRoleManager, roleMention, CommandInteraction } = require ( "discord.js" ) ;
22const ms = require ( "ms" )
33
4- const { LimitedTime, BoostWork, PrettyCurrency } = require ( "./functions" ) ;
4+ const { LimitedTime, BoostWork, PrettyCurrency, FindNewIds } = require ( "./functions" ) ;
55const { ItemObjetives, BoostObjetives, Enum, BoostTypes } = require ( "./Enums" ) ;
66const Embed = require ( "./Embed" ) ;
77
@@ -57,6 +57,7 @@ class RouletteItem {
5757 }
5858
5959 #adjust( ) {
60+ if ( this . item . target === ItemObjetives . Exp || this . item . target === ItemObjetives . Boost || this . item . target === ItemObjetives . Warns ) return ;
6061 if ( this . doc . toAdjust ( "roulette" ) ) {
6162 this . numbers = Number ( this . numbers ) ;
6263
@@ -93,6 +94,18 @@ class RouletteItem {
9394 this . target = this . user . data . temp_roles ;
9495 break ;
9596
97+ case ItemObjetives . Exp :
98+ this . target = this . user . economy . global . exp ;
99+ this . frontend_target = `\`${ this . target . toLocaleString ( "es-CO" ) } \` EXP antes` ;
100+ this . frontend_numbers = `\`${ this . numbers . toLocaleString ( "es-CO" ) } \` EXP` ;
101+ break ;
102+
103+ case ItemObjetives . Warns :
104+ this . target = this . user . warns ;
105+ this . frontend_target = `\`${ this . target . length . toLocaleString ( "es-CO" ) } \` Warns antes` ;
106+ this . frontend_numbers = `\`${ this . numbers . toLocaleString ( "es-CO" ) } \` Warns` ;
107+ break ;
108+
96109 default :
97110 this . target = null ;
98111 }
@@ -123,17 +136,32 @@ class RouletteItem {
123136
124137 case Array :
125138 let temproles = Number ( this . item . target ) === ItemObjetives . Boost ;
139+ let warns = Number ( this . item . target ) === ItemObjetives . Warns ;
140+
126141 if ( this . nonumbers === '-' ) {
127142 response = temproles ? this . removedTemp : this . success ;
128143 let i = this . target . findIndex ( x => x === this . numbers )
129- if ( temproles ) i = this . target . findIndex ( x => x . role_id === this . numbers )
130-
131- this . target . splice ( i , 1 ) ;
144+ if ( temproles ) {
145+ i = this . target . findIndex ( x => x . role_id === this . numbers )
146+ this . target . splice ( i , 1 ) ;
147+ } else if ( warns ) {
148+ let count = this . target . length > 0 ? Math . min ( this . target . length , this . numbers ) : 0 ;
149+ this . target . splice ( 0 , count ) ;
150+ }
132151 } else if ( this . nonumbers === '+' ) {
133152 if ( temproles ) {
134153 response = this . addedTemp ;
135154
136155 this . user = await LimitedTime ( this . interaction . member , null , ms ( this . item . extra . duration ) , { } , this . item . extra . boosttype , this . item . extra . boostobj , this . item . extra . boostvalue , false , this . user ) ;
156+ } else if ( warns ) {
157+ const warns = this . user . warns ;
158+ const ids = FindNewIds ( await Users . find ( ) , "warns" , "id" , this . numbers ) ;
159+
160+ for ( let i = 0 ; i < this . numbers ; i ++ ) {
161+ const id = ids . shift ( ) ;
162+ this . user . addCount ( "warns" , 1 , false ) ;
163+ warns . push ( { rule_id : 0 , id } ) ;
164+ }
137165 } else
138166 this . target . push ( this . numbers )
139167 }
@@ -148,24 +176,41 @@ class RouletteItem {
148176 this . #adjust( ) ;
149177 this . nonumbers = "Se descontaron" ;
150178
151- if ( boost . multiplier . changed . currency ) {
152- this . numbers = Number ( ( this . numbers * boost . multiplier . currency_value ) . toFixed ( 2 ) )
153- this . frontend_numbers = PrettyCurrency ( this . interaction . guild , this . numbers , { boostemoji : boost . emojis . currency } ) ;
154- }
179+ if ( this . item . target === ItemObjetives . Currency ) {
180+
181+ if ( boost . multiplier . changed . currency ) {
182+ this . numbers = Number ( ( this . numbers * boost . multiplier . currency_value ) . toFixed ( 2 ) )
183+ this . frontend_numbers = PrettyCurrency ( this . interaction . guild , this . numbers , { boostemoji : boost . emojis . currency } ) ;
184+ }
155185
156- await this . user . removeCurrency ( this . numbers ) ;
157- await this . doc . addToBank ( this . numbers , "gambling" ) ;
186+ await this . user . removeCurrency ( this . numbers ) ;
187+ await this . doc . addToBank ( this . numbers , "gambling" ) ;
188+ } else if ( this . item . target === ItemObjetives . Exp ) {
189+ if ( boost . multiplier . changed . exp ) {
190+ this . numbers = Number ( ( this . numbers * boost . multiplier . exp_value ) . toFixed ( 2 ) )
191+ }
192+
193+ this . user . economy . global . exp -= this . numbers ;
194+ }
158195 }
159196 else if ( this . nonumbers === "+" ) {
160197 this . #adjust( ) ;
161198 this . nonumbers = "Se agregaron" ;
162199
163- if ( boost . multiplier . changed . currency ) {
164- this . numbers = Number ( ( this . numbers * boost . multiplier . currency_value ) . toFixed ( 2 ) )
165- this . frontend_numbers = PrettyCurrency ( this . interaction . guild , this . numbers , { boostemoji : boost . emojis . currency } ) ;
166- }
200+ if ( this . item . target === ItemObjetives . Currency ) {
201+ if ( boost . multiplier . changed . currency ) {
202+ this . numbers = Number ( ( this . numbers * boost . multiplier . currency_value ) . toFixed ( 2 ) )
203+ this . frontend_numbers = PrettyCurrency ( this . interaction . guild , this . numbers , { boostemoji : boost . emojis . currency } ) ;
204+ }
167205
168- await this . user . addCurrency ( this . numbers , false ) ;
206+ await this . user . addCurrency ( this . numbers , false ) ;
207+ } else if ( this . item . target === ItemObjetives . Exp ) {
208+ if ( boost . multiplier . changed . exp ) {
209+ this . numbers = Number ( ( this . numbers * boost . multiplier . exp_value ) . toFixed ( 2 ) )
210+ }
211+
212+ this . user . economy . global . exp += this . numbers ;
213+ }
169214 }
170215 else if ( this . nonumbers === "*" ) {
171216 this . nonumbers = "Se multiplicó por"
@@ -183,7 +228,7 @@ class RouletteItem {
183228 response = this . success ;
184229 break ;
185230 }
186-
231+
187232 if ( ! response ) response = this . success ;
188233
189234 await this . interaction . editReply ( { embeds : [ response ] } )
@@ -246,6 +291,14 @@ class RouletteItem {
246291 }
247292 translated . text = `${ translated . action } **Un Boost ${ translated . boost . type } x${ translated . boost . value . toLocaleString ( "es-CO" ) } para ${ translated . boost . objetive } **`
248293 break ;
294+
295+ case ItemObjetives . Exp :
296+ translated . text = `${ translated . action } \`${ translated . quantity . toLocaleString ( "es-CO" ) } \` EXP`
297+ break ;
298+
299+ case ItemObjetives . Warns :
300+ translated . text = `${ translated . action } \`${ translated . quantity . toLocaleString ( "es-CO" ) } \` Warns`
301+ break ;
249302 }
250303
251304 return translated ;
0 commit comments