@@ -5,13 +5,14 @@ const settings = require('./settings.json');
5
5
const _ = require ( 'lodash' ) ;
6
6
7
7
const Discord = require ( 'discord.js' ) ;
8
- const client = global . client = new Discord . Client ( { partials : [ 'MESSAGE' , 'CHANNEL' , 'REACTION' ] } ) ;
8
+ const client = global . client = new Discord . Client ( { partials : [ 'MESSAGE' , 'CHANNEL' , 'REACTION' , 'GUILD_PRESENCES' ] } ) ;
9
9
10
10
const nconf = require ( 'nconf' ) ;
11
11
const Memory = nconf . file ( 'memory.json' ) ;
12
12
13
13
const { GameRoomManager } = require ( './utils/gamemanager' ) ;
14
14
const { StatsManager } = require ( './utils/statsmanager' ) ;
15
+ const { CodesManager } = require ( './utils/codesmanager' ) ;
15
16
16
17
const say = require ( 'say' ) ;
17
18
@@ -93,6 +94,7 @@ function tts(voiceChannel, text) {
93
94
}
94
95
} ) ;
95
96
}
97
+ const sleep = ( delay ) => new Promise ( ( resolve ) => setTimeout ( resolve , delay ) ) ;
96
98
97
99
// Events
98
100
fs . readdir ( './events/' , ( err , files ) => {
@@ -124,43 +126,7 @@ client.on('message', async msg => {
124
126
// Check for codes (6 chars) && user in-voice
125
127
if ( msg . content . length == 6 && member . voice . channelID !== undefined ) {
126
128
const code = msg . content ;
127
- const library = {
128
- 'A' : [ 'Albacete' ] ,
129
- 'B' : [ 'Barcelona' ] ,
130
- 'C' : [ 'Casa' ] ,
131
- 'D' : [ 'Dinamarca' ] ,
132
- 'E' : [ 'España' ] ,
133
- 'F' : [ 'Francia' , 'Furcia' ] ,
134
- 'G' : [ 'Gato' ] ,
135
- 'H' : [ 'Helado' ] ,
136
- 'I' : [ 'Italia' ] ,
137
- 'J' : [ 'Jaen' ] ,
138
- 'K' : [ 'Kilo' ] ,
139
- 'L' : [ 'Lugo' ] ,
140
- 'M' : [ 'Madrid' ] ,
141
- 'N' : [ 'Noruega' ] ,
142
- 'O' : [ 'Oviedo' ] ,
143
- 'P' : [ 'Pamplona' ] ,
144
- 'Q' : [ 'Queso' ] ,
145
- 'R' : [ 'Roma' ] ,
146
- 'S' : [ 'Sevilla' ] ,
147
- 'T' : [ 'Toledo' ] ,
148
- 'U' : [ 'Ucrania' ] ,
149
- 'V' : [ 'Valencia' ] ,
150
- 'W' : [ 'Washington' ] ,
151
- 'X' : [ 'Xilofono' ] ,
152
- 'Y' : [ 'Yogurt' ] ,
153
- 'Z' : [ 'Zapato' ] ,
154
- } ;
155
- let frase_completa = '' ;
156
- for ( let i = 0 ; i < code . length ; i ++ ) {
157
- const letter = code . charAt ( i ) ;
158
- const city_array = library [ letter . toUpperCase ( ) ] ;
159
- const city = city_array [ Math . floor ( Math . random ( ) * city_array . length ) ] ;
160
- frase_completa += letter + ' de ' + city + '. ' ;
161
- }
162
-
163
- tts ( member . voice . channel , frase_completa ) ;
129
+ CodesManager . generateCodeAnounce ( code , member . voice . channel ) ;
164
130
}
165
131
}
166
132
@@ -300,12 +266,46 @@ client.on('message', async msg => {
300
266
// Command: muteall
301
267
if ( command === 'muteall' ) {
302
268
269
+ const sala_roja = '753653471479332905' ;
270
+ if ( member === null ) { // webhook
271
+ const mute_state = args [ 0 ] == 1 ? true : false ;
272
+ const emoji = args [ 1 ] ;
273
+ let gamechannel = msg . guild . channels . cache . find ( c => c . name . includes ( emoji ) ) ;
274
+ if ( gamechannel == undefined ) {
275
+ gamechannel = msg . guild . channels . cache . get ( sala_roja ) ;
276
+ }
277
+ gamechannel . members . forEach ( async ( _member ) => {
278
+ await _member . voice . setMute ( mute_state ) ;
279
+ } ) ;
280
+ return ;
281
+ }
282
+
283
+ // Required to be in a voice channel
284
+ if ( member . voice . channelID === undefined ) {
285
+ return msg . reply ( 'Primero tienes que estar dentro de un canal de voz.' ) ;
286
+ }
287
+
288
+ // Argumentos
289
+ if ( args . length !== 1 ) {
290
+ return msg . reply ( 'Falta el argumento 1 o 0' ) ;
291
+ }
292
+ const mute_state = args [ 0 ] == 1 ? true : false ;
293
+
294
+ member . voice . channel . members . forEach ( async ( _member ) => {
295
+ await _member . voice . setMute ( mute_state ) ;
296
+ } ) ;
297
+ }
298
+
299
+ // Command: supermute
300
+ if ( command === 'supermute' ) {
301
+
303
302
const sala_roja = '753653471479332905' ;
304
303
if ( member === null ) {
305
304
const mute_state = args [ 0 ] == 1 ? true : false ;
306
305
const channel = msg . guild . channels . cache . get ( sala_roja ) ;
307
306
channel . members . forEach ( async ( _member ) => {
308
307
await _member . voice . setMute ( mute_state ) ;
308
+ await _member . voice . setDeaf ( mute_state ) ;
309
309
} ) ;
310
310
return ;
311
311
}
@@ -323,9 +323,11 @@ client.on('message', async msg => {
323
323
324
324
member . voice . channel . members . forEach ( async ( _member ) => {
325
325
await _member . voice . setMute ( mute_state ) ;
326
+ await _member . voice . setDeaf ( mute_state ) ;
326
327
} ) ;
327
328
}
328
329
330
+ // say command
329
331
if ( command === 'say' ) {
330
332
// Required to be in a voice channel
331
333
if ( member . voice . channelID === undefined ) {
0 commit comments