qwtf_discord_bot 5.4.5 → 5.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/qwtf_discord_bot/qwtf_discord_bot_pug.rb +301 -83
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f57dc18281f366be0004ffcf3ab6a35938b155c5897922c28cba7c6cf7e18b5
|
4
|
+
data.tar.gz: a27fcdd5f32203382595bc5b135af9940690fc0b45f7dbd6a5e019777de0ff5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3d452a44dd1506cad8d214089737a0f515edabd2fe189bb437a321d624346ecd1795fa0bcb79bd8734d9f56f952c41e7aec49126a563bda7fbb8d313676cc24
|
7
|
+
data.tar.gz: 0df2e2073331e1cec5332bf7d680bb9715c789d2bac18ccf9750d48d7b4df1eb7a46c515f38a14597aa99de206b58392a41e613f5060b4f2b82c4438797c298b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.4.
|
1
|
+
5.4.6
|
@@ -7,7 +7,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
7
7
|
include QwtfDiscordBot
|
8
8
|
|
9
9
|
MSG_SNIPPET_DELIMITER = ' · '
|
10
|
-
TEAM_NAMES = {
|
10
|
+
TEAM_NAMES = { 1 => "Blue", 2 => "Red" }
|
11
11
|
|
12
12
|
def run
|
13
13
|
bot = Discordrb::Commands::CommandBot.new(
|
@@ -31,7 +31,12 @@ class QwtfDiscordBotPug # :nodoc:
|
|
31
31
|
|
32
32
|
bot.command :join do |event, *args|
|
33
33
|
setup_pug(event) do |e, pug|
|
34
|
-
|
34
|
+
if pug.joined?(e.user_id)
|
35
|
+
return send_embedded_message(
|
36
|
+
description: "You've already joined",
|
37
|
+
channel: e.channel
|
38
|
+
)
|
39
|
+
end
|
35
40
|
|
36
41
|
join_pug(e, pug)
|
37
42
|
start_pug(pug, e) if pug.full?
|
@@ -40,7 +45,12 @@ class QwtfDiscordBotPug # :nodoc:
|
|
40
45
|
|
41
46
|
bot.command :choose do |event, *args|
|
42
47
|
setup_pug(event) do |e, pug|
|
43
|
-
|
48
|
+
if !pug.full?
|
49
|
+
return send_embedded_message(
|
50
|
+
description: "Can't choose teams until PUG is full",
|
51
|
+
channel: e.channel
|
52
|
+
)
|
53
|
+
end
|
44
54
|
|
45
55
|
pug.joined_players.each do |player_id|
|
46
56
|
pug.join_team(team_no: 0, player_id: player_id)
|
@@ -52,14 +62,22 @@ class QwtfDiscordBotPug # :nodoc:
|
|
52
62
|
|
53
63
|
bot.command :status do |event, *args|
|
54
64
|
setup_pug(event) do |e, pug|
|
55
|
-
|
65
|
+
if !pug.active?
|
66
|
+
return send_embedded_message(
|
67
|
+
description: "No PUG has been started. `!join` to create",
|
68
|
+
channel: e.channel
|
69
|
+
)
|
70
|
+
end
|
56
71
|
|
57
72
|
footer = [
|
58
73
|
pug.game_map,
|
59
74
|
"#{pug.player_slots} joined",
|
60
75
|
].compact.join(MSG_SNIPPET_DELIMITER)
|
61
76
|
|
62
|
-
send_embedded_message(
|
77
|
+
send_embedded_message(
|
78
|
+
description: nil,
|
79
|
+
channel: e.channel
|
80
|
+
) do |embed|
|
63
81
|
embed.footer = Discordrb::Webhooks::EmbedFooter.new(
|
64
82
|
text: footer
|
65
83
|
)
|
@@ -85,39 +103,54 @@ class QwtfDiscordBotPug # :nodoc:
|
|
85
103
|
|
86
104
|
bot.command :teamsize do |event, *args|
|
87
105
|
setup_pug(event) do |e, pug|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
if new_teamsize
|
94
|
-
pug.teamsize = new_teamsize
|
95
|
-
|
96
|
-
send_embedded_message(
|
97
|
-
[
|
98
|
-
"Team size set to #{pug.teamsize}",
|
106
|
+
unless args.any?
|
107
|
+
return send_embedded_message(
|
108
|
+
description: [
|
109
|
+
"Each team has #{pug.teamsize} players",
|
99
110
|
"#{pug.player_slots} joined"
|
100
111
|
].join(MSG_SNIPPET_DELIMITER),
|
101
|
-
e.channel
|
112
|
+
channel: e.channel
|
102
113
|
)
|
114
|
+
end
|
103
115
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
].join(MSG_SNIPPET_DELIMITER),
|
111
|
-
e.channel
|
116
|
+
new_teamsize = args[0].to_i
|
117
|
+
|
118
|
+
if new_teamsize < 1
|
119
|
+
return send_embedded_message(
|
120
|
+
description: "Team size should be 1 or more",
|
121
|
+
channel: e.channel
|
112
122
|
)
|
113
123
|
end
|
124
|
+
|
125
|
+
pug.teamsize = new_teamsize
|
126
|
+
|
127
|
+
send_embedded_message(
|
128
|
+
description: [
|
129
|
+
"Each team has #{pug.teamsize} players",
|
130
|
+
"#{pug.player_slots} joined"
|
131
|
+
].join(MSG_SNIPPET_DELIMITER),
|
132
|
+
channel: e.channel
|
133
|
+
)
|
134
|
+
|
135
|
+
start_pug(pug, e) if pug.full?
|
114
136
|
end
|
115
137
|
end
|
116
138
|
|
117
139
|
bot.command :leave do |event, *args|
|
118
140
|
setup_pug(event) do |e, pug|
|
119
|
-
|
120
|
-
|
141
|
+
unless pug.active?
|
142
|
+
return send_embedded_message(
|
143
|
+
description: no_active_pug_message,
|
144
|
+
channel: e.channel
|
145
|
+
)
|
146
|
+
end
|
147
|
+
|
148
|
+
unless pug.joined?(e.user_id)
|
149
|
+
return send_embedded_message(
|
150
|
+
description: "You're not in the PUG",
|
151
|
+
channel: e.channel
|
152
|
+
)
|
153
|
+
end
|
121
154
|
|
122
155
|
pug.leave(e.user_id)
|
123
156
|
|
@@ -126,11 +159,12 @@ class QwtfDiscordBotPug # :nodoc:
|
|
126
159
|
"#{pug.player_slots} remain"
|
127
160
|
]
|
128
161
|
|
129
|
-
|
162
|
+
message = "#{pug.slots_left} more #{pug.notify_roles}" if pug.slots_left == 1
|
130
163
|
|
131
164
|
send_embedded_message(
|
132
|
-
|
133
|
-
|
165
|
+
message: message,
|
166
|
+
description: snippets.join(MSG_SNIPPET_DELIMITER),
|
167
|
+
channel: e.channel
|
134
168
|
)
|
135
169
|
|
136
170
|
end_pug(pug, e.channel) if pug.empty?
|
@@ -139,12 +173,26 @@ class QwtfDiscordBotPug # :nodoc:
|
|
139
173
|
|
140
174
|
bot.command :kick do |event, *args|
|
141
175
|
setup_pug(event) do |e, pug|
|
142
|
-
|
143
|
-
|
176
|
+
unless args.any?
|
177
|
+
return send_embedded_message(
|
178
|
+
description: "Kick who? e.g. `!kick @#{e.display_name}`",
|
179
|
+
channel: e.channel
|
180
|
+
)
|
181
|
+
end
|
182
|
+
|
183
|
+
unless pug.active?
|
184
|
+
return send_embedded_message(
|
185
|
+
description: no_active_pug_message,
|
186
|
+
channel: e.channel
|
187
|
+
)
|
188
|
+
end
|
144
189
|
|
145
190
|
args.each do |arg|
|
146
191
|
unless arg.match(/<@!\d+>/)
|
147
|
-
send_embedded_message(
|
192
|
+
send_embedded_message(
|
193
|
+
description: "#{arg} isn't a valid mention",
|
194
|
+
channel: e.channel
|
195
|
+
)
|
148
196
|
next
|
149
197
|
end
|
150
198
|
|
@@ -152,7 +200,10 @@ class QwtfDiscordBotPug # :nodoc:
|
|
152
200
|
display_name = e.display_name_for(user_id) || arg
|
153
201
|
|
154
202
|
unless pug.joined?(user_id)
|
155
|
-
send_embedded_message(
|
203
|
+
send_embedded_message(
|
204
|
+
description: "#{display_name} isn't in the PUG",
|
205
|
+
channel: e.channel
|
206
|
+
)
|
156
207
|
next
|
157
208
|
end
|
158
209
|
|
@@ -163,11 +214,12 @@ class QwtfDiscordBotPug # :nodoc:
|
|
163
214
|
"#{pug.player_slots} remain"
|
164
215
|
]
|
165
216
|
|
166
|
-
|
217
|
+
message = "#{pug.slots_left} more #{pug.notify_roles}" if pug.slots_left == 1
|
167
218
|
|
168
219
|
send_embedded_message(
|
169
|
-
|
170
|
-
|
220
|
+
message: message,
|
221
|
+
description: snippets.join(MSG_SNIPPET_DELIMITER),
|
222
|
+
channel: e.channel
|
171
223
|
)
|
172
224
|
|
173
225
|
break end_pug(pug, e.channel) if pug.empty?
|
@@ -177,29 +229,50 @@ class QwtfDiscordBotPug # :nodoc:
|
|
177
229
|
|
178
230
|
bot.command :team do |event, *args|
|
179
231
|
setup_pug(event) do |e, pug|
|
180
|
-
|
181
|
-
|
232
|
+
unless args.any?
|
233
|
+
return send_embedded_message(
|
234
|
+
description: "Which team? E.G. `!team 1`",
|
235
|
+
channel: e.channel
|
236
|
+
)
|
237
|
+
end
|
238
|
+
|
239
|
+
unless ["1", "2"].any?(args.first)
|
240
|
+
return send_embedded_message(
|
241
|
+
description: "Choose `!team 1`, `!team 2`, or `!unteam` to leave team",
|
242
|
+
channel: e.channel
|
243
|
+
)
|
244
|
+
end
|
182
245
|
|
183
246
|
team_no = args.first.to_i
|
184
247
|
pug_already_full = pug.full?
|
185
248
|
|
186
249
|
if args.count == 1
|
187
250
|
user_id = e.user_id
|
188
|
-
|
251
|
+
|
252
|
+
if pug.team(team_no).include?(user_id)
|
253
|
+
return send_embedded_message(
|
254
|
+
description: "You're already in #{TEAM_NAMES[team_no]}",
|
255
|
+
channel: e.channel
|
256
|
+
)
|
257
|
+
end
|
189
258
|
|
190
259
|
join_pug(e, pug) unless pug.joined?(user_id)
|
191
260
|
pug.join_team(team_no: team_no, player_id: user_id)
|
192
261
|
|
193
262
|
send_embedded_message(
|
194
|
-
[
|
263
|
+
description: [
|
195
264
|
"#{e.display_name} joins #{TEAM_NAMES[team_no]}",
|
196
265
|
"#{pug.team_player_count(team_no)}/#{pug.teamsize}"
|
197
|
-
].join(MSG_SNIPPET_DELIMITER),
|
266
|
+
].join(MSG_SNIPPET_DELIMITER),
|
267
|
+
channel: e.channel
|
198
268
|
)
|
199
269
|
else
|
200
270
|
args[1..-1].each do |mention|
|
201
271
|
unless mention.match(/<@!\d+>/)
|
202
|
-
send_embedded_message(
|
272
|
+
send_embedded_message(
|
273
|
+
description: "#{arg} isn't a valid mention",
|
274
|
+
channel: e.channel
|
275
|
+
)
|
203
276
|
next
|
204
277
|
end
|
205
278
|
|
@@ -207,17 +280,21 @@ class QwtfDiscordBotPug # :nodoc:
|
|
207
280
|
display_name = e.display_name_for(user_id) || arg
|
208
281
|
|
209
282
|
unless pug.joined?(user_id)
|
210
|
-
send_embedded_message(
|
283
|
+
send_embedded_message(
|
284
|
+
description: "#{display_name} isn't in the PUG",
|
285
|
+
channel: e.channel
|
286
|
+
)
|
211
287
|
next
|
212
288
|
end
|
213
289
|
|
214
290
|
pug.join_team(team_no: team_no, player_id: user_id)
|
215
291
|
|
216
292
|
send_embedded_message(
|
217
|
-
[
|
293
|
+
description: [
|
218
294
|
"#{display_name} joins #{TEAM_NAMES[team_no]}",
|
219
295
|
"#{pug.team_player_count(team_no)}/#{pug.teamsize}"
|
220
|
-
].join(MSG_SNIPPET_DELIMITER),
|
296
|
+
].join(MSG_SNIPPET_DELIMITER),
|
297
|
+
channel: e.channel
|
221
298
|
)
|
222
299
|
end
|
223
300
|
end
|
@@ -229,26 +306,66 @@ class QwtfDiscordBotPug # :nodoc:
|
|
229
306
|
bot.command :unteam do |event, *args|
|
230
307
|
setup_pug(event) do |e, pug|
|
231
308
|
user_id = e.user_id
|
232
|
-
|
233
|
-
|
234
|
-
|
309
|
+
|
310
|
+
unless pug.active?
|
311
|
+
return send_embedded_message(
|
312
|
+
description: 'No PUG has been started. `!join` to create',
|
313
|
+
channel: e.channel
|
314
|
+
)
|
315
|
+
end
|
316
|
+
|
317
|
+
unless pug.joined?(user_id)
|
318
|
+
return send_embedded_message(
|
319
|
+
description: "You aren't in this PUG",
|
320
|
+
channel: e.channel
|
321
|
+
)
|
322
|
+
end
|
323
|
+
|
324
|
+
if pug.team(0).include?(user_id)
|
325
|
+
return send_embedded_message(
|
326
|
+
description: "You aren't in a team",
|
327
|
+
channel: e.channel
|
328
|
+
)
|
329
|
+
end
|
235
330
|
|
236
331
|
pug.join_team(team_no: 0, player_id: user_id)
|
237
|
-
|
332
|
+
|
333
|
+
send_embedded_message(
|
334
|
+
description: "#{e.display_name} leaves team",
|
335
|
+
channel: e.channel
|
336
|
+
)
|
238
337
|
end
|
239
338
|
end
|
240
339
|
|
241
340
|
bot.command :win do |event, *args|
|
242
341
|
setup_pug(event) do |e, pug|
|
243
|
-
|
244
|
-
|
245
|
-
|
342
|
+
unless pug.active?
|
343
|
+
return send_embedded_message(
|
344
|
+
description: no_active_pug_message,
|
345
|
+
channel: e.channel
|
346
|
+
)
|
347
|
+
end
|
348
|
+
|
349
|
+
unless args.any?
|
350
|
+
return send_embedded_message(
|
351
|
+
description: "Specify winning team; e.g. `!win 1`",
|
352
|
+
channel: e.channel
|
353
|
+
)
|
354
|
+
end
|
355
|
+
|
356
|
+
unless ["1", "2"].any?(args.first)
|
357
|
+
return send_embedded_message(
|
358
|
+
description: "Invalid team number",
|
359
|
+
channel: e.channel
|
360
|
+
)
|
361
|
+
end
|
246
362
|
|
247
363
|
winning_team_no = args.first.to_i
|
248
364
|
|
249
365
|
if pug.actual_teams.count < 2
|
250
366
|
return send_embedded_message(
|
251
|
-
"There must be at least two teams with players to submit a result",
|
367
|
+
description: "There must be at least two teams with players to submit a result",
|
368
|
+
channel: e.channel
|
252
369
|
)
|
253
370
|
end
|
254
371
|
|
@@ -274,17 +391,26 @@ class QwtfDiscordBotPug # :nodoc:
|
|
274
391
|
}.to_json
|
275
392
|
)
|
276
393
|
|
277
|
-
send_embedded_message(
|
394
|
+
send_embedded_message(
|
395
|
+
description: "#{TEAM_NAMES[winning_team_no]} wins. [Ratings](http://ratings.fortressone.org)",
|
396
|
+
channel: e.channel
|
397
|
+
)
|
278
398
|
end
|
279
399
|
end
|
280
400
|
|
281
401
|
bot.command :draw do |event, *args|
|
282
402
|
setup_pug(event) do |e, pug|
|
283
|
-
|
403
|
+
unless pug.active?
|
404
|
+
return send_embedded_message(
|
405
|
+
description: no_active_pug_message,
|
406
|
+
channel: e.channel
|
407
|
+
)
|
408
|
+
end
|
284
409
|
|
285
410
|
if pug.actual_teams.count < 2
|
286
411
|
return send_embedded_message(
|
287
|
-
"There must be at least two teams with players to submit a result",
|
412
|
+
description: "There must be at least two teams with players to submit a result",
|
413
|
+
channel: e.channel
|
288
414
|
)
|
289
415
|
end
|
290
416
|
|
@@ -309,13 +435,21 @@ class QwtfDiscordBotPug # :nodoc:
|
|
309
435
|
}.to_json
|
310
436
|
)
|
311
437
|
|
312
|
-
send_embedded_message(
|
438
|
+
send_embedded_message(
|
439
|
+
description: "Match drawn. [Ratings](http://ratings.fortressone.org)",
|
440
|
+
channel: e.channel
|
441
|
+
)
|
313
442
|
end
|
314
443
|
end
|
315
444
|
|
316
445
|
bot.command :end do |event, *args|
|
317
446
|
setup_pug(event) do |e, pug|
|
318
|
-
|
447
|
+
unless pug.active?
|
448
|
+
return send_embedded_message(
|
449
|
+
description: no_active_pug_message,
|
450
|
+
channel: e.channel
|
451
|
+
)
|
452
|
+
end
|
319
453
|
|
320
454
|
end_pug(pug, e.channel)
|
321
455
|
end
|
@@ -324,47 +458,105 @@ class QwtfDiscordBotPug # :nodoc:
|
|
324
458
|
bot.command :addmap do |event, *args|
|
325
459
|
setup_pug(event) do |e, pug|
|
326
460
|
maps = args
|
327
|
-
|
461
|
+
|
462
|
+
unless maps.any?
|
463
|
+
return send_embedded_message(
|
464
|
+
description: "What map? e.g. `!addmap 2fort5r`",
|
465
|
+
channel: e.channel
|
466
|
+
)
|
467
|
+
end
|
328
468
|
|
329
469
|
pug.add_maps(maps)
|
330
|
-
|
470
|
+
|
471
|
+
send_embedded_message(
|
472
|
+
description: "#{maps.join(', ')} added to maps",
|
473
|
+
channel: e.channel)
|
331
474
|
end
|
332
475
|
end
|
333
476
|
|
334
477
|
bot.command :removemap do |event, *args|
|
335
478
|
setup_pug(event) do |e, pug|
|
336
479
|
maps = args
|
337
|
-
|
480
|
+
|
481
|
+
unless maps.any?
|
482
|
+
return send_embedded_message(
|
483
|
+
description: "What map? e.g. `!removemap 2fort5r`",
|
484
|
+
channel: e.channel
|
485
|
+
)
|
486
|
+
end
|
338
487
|
|
339
488
|
pug.remove_maps(maps)
|
340
|
-
|
489
|
+
|
490
|
+
send_embedded_message(
|
491
|
+
description: "#{maps.join(', ')} removed from maps",
|
492
|
+
channel: e.channel
|
493
|
+
)
|
341
494
|
end
|
342
495
|
end
|
343
496
|
|
344
497
|
bot.command :maps do |event, *args|
|
345
498
|
setup_pug(event) do |e, pug|
|
346
499
|
maps = pug.maps
|
347
|
-
|
500
|
+
unless maps.any?
|
501
|
+
return send_embedded_message(
|
502
|
+
description: 'No maps have been added. `!addmap`',
|
503
|
+
channel: e.channel
|
504
|
+
)
|
505
|
+
end
|
348
506
|
|
349
|
-
send_embedded_message(
|
507
|
+
send_embedded_message(
|
508
|
+
description: maps.join(', '),
|
509
|
+
channel: e.channel
|
510
|
+
)
|
350
511
|
end
|
351
512
|
end
|
352
513
|
|
353
514
|
bot.command :map do |event, *args|
|
354
515
|
setup_pug(event) do |e, pug|
|
355
516
|
maps = pug.maps
|
356
|
-
|
357
|
-
|
517
|
+
|
518
|
+
unless maps.any?
|
519
|
+
return send_embedded_message(
|
520
|
+
description: 'No maps have been added. `!addmap`',
|
521
|
+
channel: e.channel
|
522
|
+
)
|
523
|
+
end
|
524
|
+
|
525
|
+
unless pug.active?
|
526
|
+
return send_embedded_message(
|
527
|
+
description: no_active_pug_message,
|
528
|
+
channel: e.channel
|
529
|
+
)
|
530
|
+
end
|
358
531
|
|
359
532
|
if args.empty?
|
360
|
-
|
361
|
-
|
533
|
+
unless pug.game_map
|
534
|
+
return send_embedded_message(
|
535
|
+
description: 'No map has been set for the current PUG',
|
536
|
+
channel: e.channel
|
537
|
+
)
|
538
|
+
end
|
539
|
+
|
540
|
+
send_embedded_message(
|
541
|
+
description: "Current map is #{pug.game_map}",
|
542
|
+
channel: e.channel
|
543
|
+
)
|
362
544
|
else
|
363
545
|
game_map = args.first
|
364
|
-
|
546
|
+
|
547
|
+
unless maps.include?(game_map)
|
548
|
+
return send_embedded_message(
|
549
|
+
description: "#{game_map} isn't in the map list. `!addmap` to add it.",
|
550
|
+
channel: e.channel
|
551
|
+
)
|
552
|
+
end
|
365
553
|
|
366
554
|
pug.game_map = game_map
|
367
|
-
|
555
|
+
|
556
|
+
send_embedded_message(
|
557
|
+
description: "Map set to #{game_map}",
|
558
|
+
channel: e.channel
|
559
|
+
)
|
368
560
|
end
|
369
561
|
end
|
370
562
|
end
|
@@ -380,7 +572,10 @@ class QwtfDiscordBotPug # :nodoc:
|
|
380
572
|
"Notification role set to #{roles}"
|
381
573
|
end
|
382
574
|
|
383
|
-
send_embedded_message(
|
575
|
+
send_embedded_message(
|
576
|
+
description: msg,
|
577
|
+
channel: e.channel
|
578
|
+
)
|
384
579
|
end
|
385
580
|
end
|
386
581
|
|
@@ -390,6 +585,8 @@ class QwtfDiscordBotPug # :nodoc:
|
|
390
585
|
private
|
391
586
|
|
392
587
|
def team_name(team_no)
|
588
|
+
return "No team" if team_no == 0
|
589
|
+
|
393
590
|
[team_no, TEAM_NAMES[team_no]].join(" ")
|
394
591
|
end
|
395
592
|
|
@@ -401,13 +598,18 @@ class QwtfDiscordBotPug # :nodoc:
|
|
401
598
|
pug.join(e.user_id)
|
402
599
|
|
403
600
|
if pug.joined_player_count == 1
|
404
|
-
snippets = ["#{e.display_name} creates a PUG", pug.player_slots
|
601
|
+
snippets = ["#{e.display_name} creates a PUG", "#{pug.player_slots} joined"]
|
602
|
+
message = pug.notify_roles
|
405
603
|
else
|
406
|
-
snippets = ["#{e.display_name} joins the PUG", pug.player_slots]
|
407
|
-
|
604
|
+
snippets = ["#{e.display_name} joins the PUG", "#{pug.player_slots} joined"]
|
605
|
+
message = "#{pug.slots_left} more #{pug.notify_roles}" if pug.slots_left.between?(1, 3)
|
408
606
|
end
|
409
607
|
|
410
|
-
send_embedded_message(
|
608
|
+
send_embedded_message(
|
609
|
+
message: message,
|
610
|
+
description: snippets.join(MSG_SNIPPET_DELIMITER),
|
611
|
+
channel: e.channel
|
612
|
+
)
|
411
613
|
end
|
412
614
|
|
413
615
|
def setup_pug(event)
|
@@ -419,7 +621,10 @@ class QwtfDiscordBotPug # :nodoc:
|
|
419
621
|
|
420
622
|
def start_pug(pug, event)
|
421
623
|
if !pug.actual_teams.any?
|
422
|
-
send_embedded_message(
|
624
|
+
send_embedded_message(
|
625
|
+
description: "Choosing fair teams...",
|
626
|
+
channel: event.channel
|
627
|
+
)
|
423
628
|
teams = get_fair_teams(pug.joined_players)
|
424
629
|
|
425
630
|
teams.each do |team_no, player_ids|
|
@@ -434,14 +639,23 @@ class QwtfDiscordBotPug # :nodoc:
|
|
434
639
|
"#{pug.player_slots} joined",
|
435
640
|
].compact.join(MSG_SNIPPET_DELIMITER)
|
436
641
|
|
437
|
-
|
642
|
+
mentions = pug.joined_players.map do |player_id|
|
643
|
+
event.mention_for(player_id)
|
644
|
+
end
|
645
|
+
|
646
|
+
mention_line = "Time to play! #{mentions.join(" ")}"
|
647
|
+
|
648
|
+
send_embedded_message(
|
649
|
+
message: mention_line,
|
650
|
+
channel: event.channel
|
651
|
+
) do |embed|
|
438
652
|
embed.footer = Discordrb::Webhooks::EmbedFooter.new(
|
439
653
|
text: footer
|
440
654
|
)
|
441
655
|
|
442
656
|
pug.teams.each do |team_no, player_ids|
|
443
657
|
team_mentions = player_ids.map do |player_id|
|
444
|
-
event.
|
658
|
+
event.display_name_for(player_id)
|
445
659
|
end
|
446
660
|
|
447
661
|
embed.add_field(
|
@@ -459,18 +673,22 @@ class QwtfDiscordBotPug # :nodoc:
|
|
459
673
|
|
460
674
|
def end_pug(pug, channel_id)
|
461
675
|
pug.end_pug
|
462
|
-
|
676
|
+
|
677
|
+
send_embedded_message(
|
678
|
+
description: 'PUG ended',
|
679
|
+
channel: channel_id
|
680
|
+
)
|
463
681
|
end
|
464
682
|
|
465
683
|
def no_active_pug_message
|
466
684
|
"There's no active PUG"
|
467
685
|
end
|
468
686
|
|
469
|
-
def send_embedded_message(message, channel)
|
687
|
+
def send_embedded_message(message: nil, description: nil, channel:)
|
470
688
|
embed = Discordrb::Webhooks::Embed.new
|
471
|
-
embed.description =
|
689
|
+
embed.description = description
|
472
690
|
yield(embed) if block_given?
|
473
|
-
channel.send_embed(
|
691
|
+
channel.send_embed(message, embed) && puts(message)
|
474
692
|
end
|
475
693
|
|
476
694
|
def post_results(json)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qwtf_discord_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.4.
|
4
|
+
version: 5.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sheldon Johnson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: discordrb
|