@@ -45,7 +45,7 @@ describe('Bot', function () {
45
45
46
46
this . addUser = function ( user , member = null ) {
47
47
const userObj = new discord . User ( this . bot . discord , user ) ;
48
- const guildMember = Object . assign ( member || user , { user : userObj } ) ;
48
+ const guildMember = Object . assign ( { } , member || user , { user : userObj } ) ;
49
49
guildMember . nick = guildMember . nickname ; // nick => nickname in Discord API
50
50
const memberObj = new discord . GuildMember ( this . guild , guildMember ) ;
51
51
this . guild . members . set ( userObj . id , memberObj ) ;
@@ -139,7 +139,6 @@ describe('Bot', function () {
139
139
const text = 'testmessage' ;
140
140
const newConfig = { ...config , ircNickColor : false } ;
141
141
const bot = new Bot ( newConfig ) ;
142
- const guild = this . guild ;
143
142
bot . connect ( ) ;
144
143
const message = {
145
144
content : text ,
@@ -151,7 +150,7 @@ describe('Bot', function () {
151
150
username : 'otherauthor' ,
152
151
id : 'not bot id'
153
152
} ,
154
- guild
153
+ guild : this . guild
155
154
} ;
156
155
157
156
bot . sendToIRC ( message ) ;
@@ -161,7 +160,6 @@ describe('Bot', function () {
161
160
162
161
it ( 'should send correct messages to irc' , function ( ) {
163
162
const text = 'testmessage' ;
164
- const guild = this . guild ;
165
163
const message = {
166
164
content : text ,
167
165
mentions : { users : [ ] } ,
@@ -172,7 +170,7 @@ describe('Bot', function () {
172
170
username : 'otherauthor' ,
173
171
id : 'not bot id'
174
172
} ,
175
- guild
173
+ guild : this . guild
176
174
} ;
177
175
178
176
this . bot . sendToIRC ( message ) ;
@@ -183,7 +181,6 @@ describe('Bot', function () {
183
181
184
182
it ( 'should send to IRC channel mapped by discord channel ID if available' , function ( ) {
185
183
const text = 'test message' ;
186
- const guild = this . guild ;
187
184
const message = {
188
185
content : text ,
189
186
mentions : { users : [ ] } ,
@@ -195,7 +192,7 @@ describe('Bot', function () {
195
192
username : 'test' ,
196
193
id : 'not bot id'
197
194
} ,
198
- guild
195
+ guild : this . guild
199
196
} ;
200
197
201
198
// Wrap it in colors:
@@ -207,7 +204,6 @@ describe('Bot', function () {
207
204
208
205
it ( 'should send to IRC channel mapped by discord channel name if ID not available' , function ( ) {
209
206
const text = 'test message' ;
210
- const guild = this . guild ;
211
207
const message = {
212
208
content : text ,
213
209
mentions : { users : [ ] } ,
@@ -219,7 +215,7 @@ describe('Bot', function () {
219
215
username : 'test' ,
220
216
id : 'not bot id'
221
217
} ,
222
- guild
218
+ guild : this . guild
223
219
} ;
224
220
225
221
// Wrap it in colors:
@@ -231,7 +227,6 @@ describe('Bot', function () {
231
227
232
228
it ( 'should send attachment URL to IRC' , function ( ) {
233
229
const attachmentUrl = 'https://image/url.jpg' ;
234
- const guild = this . guild ;
235
230
const message = {
236
231
content : '' ,
237
232
mentions : { users : [ ] } ,
@@ -243,7 +238,7 @@ describe('Bot', function () {
243
238
username : 'otherauthor' ,
244
239
id : 'not bot id'
245
240
} ,
246
- guild
241
+ guild : this . guild
247
242
} ;
248
243
249
244
this . bot . sendToIRC ( message ) ;
@@ -254,7 +249,6 @@ describe('Bot', function () {
254
249
it ( 'should send text message and attachment URL to IRC if both exist' , function ( ) {
255
250
const text = 'Look at this cute cat picture!' ;
256
251
const attachmentUrl = 'https://image/url.jpg' ;
257
- const guild = this . guild ;
258
252
const message = {
259
253
content : text ,
260
254
attachments : createAttachments ( attachmentUrl ) ,
@@ -266,7 +260,7 @@ describe('Bot', function () {
266
260
username : 'otherauthor' ,
267
261
id : 'not bot id'
268
262
} ,
269
- guild
263
+ guild : this . guild
270
264
} ;
271
265
272
266
this . bot . sendToIRC ( message ) ;
@@ -279,7 +273,6 @@ describe('Bot', function () {
279
273
} ) ;
280
274
281
275
it ( 'should not send an empty text message with an attachment to IRC' , function ( ) {
282
- const guild = this . guild ;
283
276
const message = {
284
277
content : '' ,
285
278
attachments : createAttachments ( 'https://image/url.jpg' ) ,
@@ -291,7 +284,7 @@ describe('Bot', function () {
291
284
username : 'otherauthor' ,
292
285
id : 'not bot id'
293
286
} ,
294
- guild
287
+ guild : this . guild
295
288
} ;
296
289
297
290
this . bot . sendToIRC ( message ) ;
@@ -300,13 +293,12 @@ describe('Bot', function () {
300
293
} ) ;
301
294
302
295
it ( 'should not send its own messages to irc' , function ( ) {
303
- const guild = this . guild ;
304
296
const message = {
305
297
author : {
306
298
username : 'bot' ,
307
299
id : this . bot . discord . user . id
308
300
} ,
309
- guild
301
+ guild : this . guild
310
302
} ;
311
303
312
304
this . bot . sendToIRC ( message ) ;
@@ -315,7 +307,6 @@ describe('Bot', function () {
315
307
316
308
it ( 'should not send messages to irc if the channel isn\'t in the channel mapping' ,
317
309
function ( ) {
318
- const guild = this . guild ;
319
310
const message = {
320
311
channel : {
321
312
name : 'wrongdiscord'
@@ -324,7 +315,7 @@ describe('Bot', function () {
324
315
username : 'otherauthor' ,
325
316
id : 'not bot id'
326
317
} ,
327
- guild
318
+ guild : this . guild
328
319
} ;
329
320
330
321
this . bot . sendToIRC ( message ) ;
@@ -333,7 +324,6 @@ describe('Bot', function () {
333
324
334
325
it ( 'should parse text from discord when sending messages' , function ( ) {
335
326
const text = '<#1234>' ;
336
- const guild = this . guild ;
337
327
const message = {
338
328
content : text ,
339
329
mentions : { users : [ ] } ,
@@ -344,7 +334,7 @@ describe('Bot', function () {
344
334
username : 'test' ,
345
335
id : 'not bot id'
346
336
} ,
347
- guild
337
+ guild : this . guild
348
338
} ;
349
339
350
340
// Wrap it in colors:
@@ -356,7 +346,6 @@ describe('Bot', function () {
356
346
357
347
it ( 'should use #deleted-channel when referenced channel fails to exist' , function ( ) {
358
348
const text = '<#1235>' ;
359
- const guild = this . guild ;
360
349
const message = {
361
350
content : text ,
362
351
mentions : { users : [ ] } ,
@@ -367,7 +356,7 @@ describe('Bot', function () {
367
356
username : 'test' ,
368
357
id : 'not bot id'
369
358
} ,
370
- guild
359
+ guild : this . guild
371
360
} ;
372
361
373
362
// Discord displays "#deleted-channel" if channel doesn't exist (e.g. <#1235>)
@@ -379,7 +368,6 @@ describe('Bot', function () {
379
368
} ) ;
380
369
381
370
it ( 'should convert user mentions from discord' , function ( ) {
382
- const guild = this . guild ;
383
371
const message = {
384
372
mentions : {
385
373
users : [ {
@@ -388,14 +376,13 @@ describe('Bot', function () {
388
376
} ] ,
389
377
} ,
390
378
content : '<@123> hi' ,
391
- guild
379
+ guild : this . guild
392
380
} ;
393
381
394
382
this . bot . parseText ( message ) . should . equal ( '@testuser hi' ) ;
395
383
} ) ;
396
384
397
385
it ( 'should convert user nickname mentions from discord' , function ( ) {
398
- const guild = this . guild ;
399
386
const message = {
400
387
mentions : {
401
388
users : [ {
@@ -404,7 +391,7 @@ describe('Bot', function () {
404
391
} ] ,
405
392
} ,
406
393
content : '<@!123> hi' ,
407
- guild
394
+ guild : this . guild
408
395
} ;
409
396
410
397
this . bot . parseText ( message ) . should . equal ( '@testuser hi' ) ;
@@ -473,7 +460,6 @@ describe('Bot', function () {
473
460
474
461
it ( 'should hide usernames for commands to IRC' , function ( ) {
475
462
const text = '!test command' ;
476
- const guild = this . guild ;
477
463
const message = {
478
464
content : text ,
479
465
mentions : { users : [ ] } ,
@@ -484,7 +470,7 @@ describe('Bot', function () {
484
470
username : 'test' ,
485
471
id : 'not bot id'
486
472
} ,
487
- guild
473
+ guild : this . guild
488
474
} ;
489
475
490
476
this . bot . sendToIRC ( message ) ;
@@ -509,7 +495,6 @@ describe('Bot', function () {
509
495
const bot = new Bot ( newConfig ) ;
510
496
const id = 'not bot id' ;
511
497
const nickname = 'discord-nickname' ;
512
- const guild = this . guild ;
513
498
this . guild . members . set ( id , { nickname } ) ;
514
499
bot . connect ( ) ;
515
500
const message = {
@@ -522,7 +507,7 @@ describe('Bot', function () {
522
507
username : 'otherauthor' ,
523
508
id
524
509
} ,
525
- guild
510
+ guild : this . guild
526
511
} ;
527
512
528
513
bot . sendToIRC ( message ) ;
@@ -555,7 +540,6 @@ describe('Bot', function () {
555
540
it ( 'should convert role mentions from discord' , function ( ) {
556
541
this . addRole ( { name : 'example-role' , id : '12345' } ) ;
557
542
const text = '<@&12345>' ;
558
- const guild = this . guild ;
559
543
const message = {
560
544
content : text ,
561
545
mentions : { users : [ ] } ,
@@ -566,7 +550,7 @@ describe('Bot', function () {
566
550
username : 'test' ,
567
551
id : 'not bot id'
568
552
} ,
569
- guild
553
+ guild : this . guild
570
554
} ;
571
555
572
556
this . bot . parseText ( message ) . should . equal ( '@example-role' ) ;
@@ -576,7 +560,6 @@ describe('Bot', function () {
576
560
this . addRole ( { name : 'example-role' , id : '12345' } ) ;
577
561
578
562
const text = '<@&12346>' ;
579
- const guild = this . guild ;
580
563
const message = {
581
564
content : text ,
582
565
mentions : { users : [ ] } ,
@@ -587,7 +570,7 @@ describe('Bot', function () {
587
570
username : 'test' ,
588
571
id : 'not bot id'
589
572
} ,
590
- guild
573
+ guild : this . guild
591
574
} ;
592
575
593
576
// Discord displays "@deleted-role" if role doesn't exist (e.g. <@&12346>)
@@ -622,8 +605,6 @@ describe('Bot', function () {
622
605
623
606
bot . sendToDiscord ( 'testuser' , '#irc' , 'test message' ) ;
624
607
this . sendStub . should . have . been . calledOnce ;
625
-
626
- const guild = this . guild ;
627
608
const message = {
628
609
content : 'test message' ,
629
610
mentions : { users : [ ] } ,
@@ -634,7 +615,7 @@ describe('Bot', function () {
634
615
username : 'otherauthor' ,
635
616
id : 'not bot id'
636
617
} ,
637
- guild
618
+ guild : this . guild
638
619
} ;
639
620
640
621
bot . sendToIRC ( message ) ;
@@ -671,8 +652,6 @@ describe('Bot', function () {
671
652
672
653
this . bot . sendToDiscord ( 'testuser' , '#irc' , 'test message' ) ;
673
654
this . sendStub . should . have . been . calledOnce ;
674
-
675
- const guild = this . guild ;
676
655
const message = {
677
656
content : 'test message' ,
678
657
mentions : { users : [ ] } ,
@@ -683,7 +662,7 @@ describe('Bot', function () {
683
662
username : 'otherauthor' ,
684
663
id : 'not bot id'
685
664
} ,
686
- guild
665
+ guild : this . guild
687
666
} ;
688
667
689
668
this . bot . sendToIRC ( message ) ;
@@ -731,8 +710,6 @@ describe('Bot', function () {
731
710
const format = { ircText : '<{$nickname}> {$discordChannel} => {$ircChannel}: {$text}' } ;
732
711
this . bot = new Bot ( { ...configMsgFormatDefault , format } ) ;
733
712
this . bot . connect ( ) ;
734
-
735
- const guild = this . guild ;
736
713
const message = {
737
714
content : 'test message' ,
738
715
mentions : { users : [ ] } ,
@@ -743,7 +720,7 @@ describe('Bot', function () {
743
720
username : 'testauthor' ,
744
721
id : 'not bot id'
745
722
} ,
746
- guild
723
+ guild : this . guild
747
724
} ;
748
725
const expected = '<testauthor> #discord => #irc: test message' ;
749
726
@@ -757,7 +734,6 @@ describe('Bot', function () {
757
734
this . bot . connect ( ) ;
758
735
759
736
const text = '!testcmd' ;
760
- const guild = this . guild ;
761
737
const message = {
762
738
content : text ,
763
739
mentions : { users : [ ] } ,
@@ -768,7 +744,7 @@ describe('Bot', function () {
768
744
username : 'testauthor' ,
769
745
id : 'not bot id'
770
746
} ,
771
- guild
747
+ guild : this . guild
772
748
} ;
773
749
const expected = 'testauthor from #discord sent command to #irc:' ;
774
750
@@ -783,7 +759,6 @@ describe('Bot', function () {
783
759
this . bot . connect ( ) ;
784
760
785
761
const attachmentUrl = 'https://image/url.jpg' ;
786
- const guild = this . guild ;
787
762
const message = {
788
763
content : '' ,
789
764
mentions : { users : [ ] } ,
@@ -795,7 +770,7 @@ describe('Bot', function () {
795
770
username : 'otherauthor' ,
796
771
id : 'not bot id'
797
772
} ,
798
- guild
773
+ guild : this . guild
799
774
} ;
800
775
801
776
this . bot . sendToIRC ( message ) ;
@@ -809,7 +784,6 @@ describe('Bot', function () {
809
784
this . bot . connect ( ) ;
810
785
811
786
const text = '!testcmd' ;
812
- const guild = this . guild ;
813
787
const message = {
814
788
content : text ,
815
789
mentions : { users : [ ] } ,
@@ -820,7 +794,7 @@ describe('Bot', function () {
820
794
username : 'testauthor' ,
821
795
id : 'not bot id'
822
796
} ,
823
- guild
797
+ guild : this . guild
824
798
} ;
825
799
826
800
this . bot . sendToIRC ( message ) ;
0 commit comments