@@ -96,6 +96,7 @@ class ShowPlayerCommand(Command):
96
96
@client .tree .command ()
97
97
@app_commands .rename (command = "name" )
98
98
async def showplayer (interaction : discord .Interaction , command : str ):
99
+ """Show a single player's stats."""
99
100
player_name = json .loads (ono .get_stats (command ))
100
101
await interaction .response .send_message (embed = build_star_embed (player_name ))
101
102
@@ -112,6 +113,7 @@ class StartGameCommand(Command):
112
113
@app_commands .rename (wthr = "weather" )
113
114
@app_commands .choices (wthr = weather .weather_choices ())
114
115
async def startgame (interaction , away : str , home : str , innings : Optional [int ]= 9 , wthr : Optional [app_commands .Choice [str ]] = None , flags : Optional [str ] = "" ):
116
+ """Start a game with the given teams and, optionally, weather choice and custom inning number."""
115
117
league = None
116
118
day = None
117
119
innings = None
@@ -180,6 +182,7 @@ class StartRandomGameCommand(Command):
180
182
181
183
@client .tree .command ()
182
184
async def randomgame (interaction ):
185
+ """Start a game between two random teams."""
183
186
if config ()["game_freeze" ]:
184
187
raise CommandError ("Patch incoming. We're not allowing new games right now." )
185
188
@@ -194,11 +197,13 @@ async def randomgame(interaction):
194
197
195
198
class SaveTeamCommand (Command ):
196
199
name = "saveteam"
197
- template = """m;saveteam
200
+ template = """m;saveteam [bot ping]
198
201
[name]
199
202
[slogan]
200
203
[lineup]
201
- [rotation]"""
204
+ [rotation]
205
+
206
+ """
202
207
203
208
description = """Saves a team to the database allowing it to be used for games. Send this command at the top of a list, with entries separated by new lines (shift+enter in discord, or copy+paste from notepad).
204
209
- the first line of the list is your team's name.
@@ -207,9 +212,7 @@ class SaveTeamCommand(Command):
207
212
- the next lines are your batters' names in the order you want them to appear in your lineup, lineups can contain any number of batters between 1 and 12.
208
213
- there must be another blank line between your batters and your pitchers.
209
214
- the final lines are the names of the pitchers in your rotation, rotations can contain any number of pitchers between 1 and 8.
210
- If you did it correctly, you'll get a team embed with a prompt to confirm. hit the 👍 and your team will be saved!
211
-
212
- ***NOTE: This only functions in the bot's DMs. Do not use on a server."""
215
+ If you did it correctly, you'll get a team embed with a prompt to confirm. hit the 👍 and your team will be saved!"""
213
216
214
217
async def execute (self , msg , command , flags ):
215
218
if db .get_team (command .split ('\n ' ,1 )[1 ].split ("\n " )[0 ]) == None :
@@ -221,14 +224,20 @@ async def execute(self, msg, command, flags):
221
224
name = command .split ('\n ' ,1 )[1 ].split ('\n ' )[0 ]
222
225
raise CommandError (f"{ name } already exists. Try a new name, maybe?" )
223
226
227
+ @client .tree .command ()
228
+ async def newteam (interaction ):
229
+ """Get new team instructions. Sent privately, don't worry!"""
230
+ await interaction .response .send_message (SaveTeamCommand .template + SaveTeamCommand .description , ephemeral = True )
231
+
224
232
class AssignArchetypeCommand (Command ):
225
233
name = "archetype"
226
234
template = "m;archetype [team name]\n [player name]\n [archetype name]"
227
235
description = """Assigns an archetype to a player on your team. This can be changed at any time! For a description of a specific archetype, or a list of all archetypes, use m;archetypehelp."""
228
236
229
237
@client .tree .command ()
230
238
@app_commands .choices (archetype = archetypes .archetype_choices ())
231
- async def archetype (interaction , team : str , player : str , archetype : app_commands .Choice [str ]):
239
+ async def setarchetype (interaction , team : str , player : str , archetype : app_commands .Choice [str ]):
240
+ """Assigns an archetype to a player on an owned team. Reversible."""
232
241
try :
233
242
team = get_team_fuzzy_search (team )
234
243
player_name = player
@@ -266,6 +275,7 @@ class ArchetypeHelpCommand(Command):
266
275
@client .tree .command ()
267
276
@app_commands .choices (archetype = archetypes .archetype_choices ())
268
277
async def archetypehelp (interaction , archetype : app_commands .Choice [str ]):
278
+ """Describes a specific archetype."""
269
279
arch = archetypes .search_archetypes (archetype .value )
270
280
if arch is None :
271
281
raise CommandError ("We don't know what that archetype is. If you're trying to break new ground, here isn't the time *or* the place." )
@@ -283,6 +293,7 @@ class ViewArchetypesCommand(Command):
283
293
@client .tree .command ()
284
294
@app_commands .rename (team_name = "team" )
285
295
async def teamarchetypes (interaction , team_name : str ):
296
+ """Lists the current archetypes on a team."""
286
297
team = get_team_fuzzy_search (team_name )
287
298
if team is None :
288
299
raise CommandError ("We can't find that team, boss." )
@@ -321,6 +332,7 @@ class ShowTeamCommand(Command):
321
332
@client .tree .command ()
322
333
@app_commands .rename (team_name = "team" )
323
334
async def showteam (interaction , team_name : str ):
335
+ """Display a team's roster and relevant ratings."""
324
336
team = get_team_fuzzy_search (team_name )
325
337
if team is not None :
326
338
await interaction .response .send_message (embed = build_team_embed (team ))
@@ -356,6 +368,11 @@ class CreditCommand(Command):
356
368
async def execute (self , msg , command , flags ):
357
369
await msg .channel .send ("Our avatar was graciously provided to us, with permission, by @HetreaSky on Twitter." )
358
370
371
+ @client .tree .command ()
372
+ async def credit (interaction ):
373
+ """Show artist credit for the bot's avatar."""
374
+ await interaction .response .send_message ("Our avatar was graciously provided to us, with permission, by @HetreaSky on Twitter." )
375
+
359
376
class SwapPlayerCommand (Command ):
360
377
name = "swapsection"
361
378
template = """m;swapsection
@@ -370,7 +387,7 @@ async def execute(self, msg, command, flags):
370
387
team , owner_id = games .get_team_and_owner (team_name )
371
388
if team is None :
372
389
raise CommandError ("Can't find that team, boss. Typo?" )
373
- elif owner_id != msg . author .id and msg . author .id not in config ()["owners" ]:
390
+ elif owner_id != interaction . user .id and interaction . user .id not in config ()["owners" ]:
374
391
raise CommandError ("You're not authorized to mess with this team. Sorry, boss." )
375
392
elif not team .swap_player (player_name ):
376
393
raise CommandError ("Either we can't find that player, you've got no space on the other side, or they're your last member of that side of the roster. Can't field an empty lineup, and we *do* have rules, chief." )
@@ -381,6 +398,22 @@ async def execute(self, msg, command, flags):
381
398
except IndexError :
382
399
raise CommandError ("Three lines, remember? Command, then team, then name." )
383
400
401
+ @client .tree .command ()
402
+ @app_commands .rename (team_name = "team" , player_name = "player" )
403
+ async def swapplayer (interaction , team_name : str , player_name : str ):
404
+ """Swaps a player on an owned team between lineup and rotation."""
405
+ team , owner_id = games .get_team_and_owner (team_name )
406
+ if team is None :
407
+ raise CommandError ("Can't find that team, boss. Typo?" )
408
+ elif owner_id != interaction .user .id and interaction .user .id not in config ()["owners" ]:
409
+ raise CommandError ("You're not authorized to mess with this team. Sorry, boss." )
410
+ elif not team .swap_player (player_name ):
411
+ raise CommandError ("Either we can't find that player, you've got no space on the other side, or they're your last member of that side of the roster. Can't field an empty lineup, and we *do* have rules, chief." )
412
+ else :
413
+ await interaction .channel .send (embed = build_team_embed (team ))
414
+ games .update_team (team )
415
+ await interaction .response .send_message ("Paperwork signed, stamped, copied, and faxed up to the goddess. Xie's pretty quick with this stuff." )
416
+
384
417
class MovePlayerCommand (Command ):
385
418
name = "moveplayer"
386
419
template = """m;moveplayer
@@ -393,34 +426,38 @@ async def execute(self, msg, command, flags):
393
426
try :
394
427
team_name = command .split ("\n " )[1 ].strip ()
395
428
player_name = command .split ("\n " )[2 ].strip ()
396
- team , owner_id = games .get_team_and_owner (team_name )
397
- try :
398
- new_pos = int (command .split ("\n " )[3 ].strip ())
399
- except ValueError :
400
- raise CommandError ("Hey, quit being cheeky. We're just trying to help. Third line has to be a natural number, boss." )
401
- if owner_id != msg .author .id and msg .author .id not in config ()["owners" ]:
402
- raise CommandError ("You're not authorized to mess with this team. Sorry, boss." )
403
- else :
404
- if team .find_player (player_name )[2 ] is None or len (team .find_player (player_name )[2 ]) < new_pos :
405
- raise CommandError ("You either gave us a number that was bigger than your current roster, or we couldn't find the player on the team. Try again." )
406
-
407
- if "batter" in command .split ("\n " )[0 ].lower ():
408
- roster = team .lineup
409
- elif "pitcher" in command .split ("\n " )[0 ].lower ():
410
- roster = team .rotation
411
- else :
412
- roster = None
413
-
414
- if (roster is not None and team .slide_player_spec (player_name , new_pos , roster )) or (roster is None and team .slide_player (player_name , new_pos )):
415
- await msg .channel .send (embed = build_team_embed (team ))
416
- games .update_team (team )
417
- await msg .channel .send ("Paperwork signed, stamped, copied, and faxed up to the goddess. Xie's pretty quick with this stuff." )
418
- else :
419
- raise CommandError ("You either gave us a number that was bigger than your current roster, or we couldn't find the player on the team. Try again." )
429
+
420
430
421
431
except IndexError :
422
432
raise CommandError ("Four lines, remember? Command, then team, then name, and finally, new spot on the lineup or rotation." )
423
433
434
+ @client .tree .command ()
435
+ @app_commands .rename (team_name = "team" , player_name = "player" , is_pitcher = "pitcher" , new_pos = "newposition" )
436
+ async def moveplayer (interaction , team_name : str , player_name : str , is_pitcher : bool , new_pos : int ):
437
+ team , owner_id = games .get_team_and_owner (team_name )
438
+ if new_pos < 0 :
439
+ raise CommandError ("Hey, quit being cheeky. We're just trying to help. New position has to be a natural number, boss." )
440
+ elif owner_id != interaction .user .id and interaction .user .id not in config ()["owners" ]:
441
+ raise CommandError ("You're not authorized to mess with this team. Sorry, boss." )
442
+ elif team is None :
443
+ raise CommandError ("We can't find that team, boss. Typo?" )
444
+ else :
445
+ if team .find_player (player_name )[2 ] is None or len (team .find_player (player_name )[2 ]) < new_pos :
446
+ raise CommandError ("You either gave us a number that was bigger than your current roster, or we couldn't find the player on the team. Try again." )
447
+
448
+ if not is_pitcher :
449
+ roster = team .lineup
450
+ else :
451
+ roster = team .rotation
452
+
453
+ if (roster is not None and team .slide_player_spec (player_name , new_pos , roster )) or (roster is None and team .slide_player (player_name , new_pos )):
454
+ await msg .channel .send (embed = build_team_embed (team ))
455
+ games .update_team (team )
456
+ await msg .channel .send ("Paperwork signed, stamped, copied, and faxed up to the goddess. Xie's pretty quick with this stuff." )
457
+ else :
458
+ raise CommandError ("You either gave us a number that was bigger than your current roster, or we couldn't find the player on the team. Try again." )
459
+
460
+
424
461
class AddPlayerCommand (Command ):
425
462
name = "addplayer"
426
463
template = """m;addplayer pitcher (or m;addplayer batter)
@@ -1598,10 +1635,10 @@ async def execute(self, msg, command, flags):
1598
1635
await msg .channel .send (f"We've got { len (games .get_all_teams ())} teams! Thanks for asking." )
1599
1636
1600
1637
commands = [
1601
- IntroduceCommand (),
1602
- CountActiveGamesCommand (),
1638
+ IntroduceCommand (), #not needed
1639
+ CountActiveGamesCommand (), #owner only
1603
1640
TeamsInfoCommand (),
1604
- AssignOwnerCommand (),
1641
+ AssignOwnerCommand (), #owner only
1605
1642
ShowPlayerCommand (), #done
1606
1643
SaveTeamCommand (), #done
1607
1644
AssignArchetypeCommand (), #done
@@ -1615,7 +1652,7 @@ async def execute(self, msg, command, flags):
1615
1652
ReplacePlayerCommand (),
1616
1653
DeleteTeamCommand (),
1617
1654
ShowTeamCommand (), #done
1618
- SearchTeamsCommand (),
1655
+ SearchTeamsCommand (), #not needed
1619
1656
StartGameCommand (), #done
1620
1657
StartRandomGameCommand (), #done
1621
1658
StartTournamentCommand (),
@@ -1642,8 +1679,8 @@ async def execute(self, msg, command, flags):
1642
1679
LeagueReplaceTeamCommand (),
1643
1680
LeagueRenameCommand (),
1644
1681
LeagueForceStopCommand (),
1645
- CreditCommand (),
1646
- RomanCommand (),
1682
+ CreditCommand (), #done
1683
+ RomanCommand (), #not needed
1647
1684
HelpCommand (),
1648
1685
StartDraftCommand (),
1649
1686
DraftFlagsCommand (),
0 commit comments