added input validation and responses to leagueswapteam

This commit is contained in:
Sakimori 2021-02-11 19:30:48 -05:00
parent eced244398
commit f0d589fecd

View file

@ -1143,14 +1143,23 @@ class LeagueSwapTeamCommand(Command):
except IndexError: except IndexError:
await msg.channel.send("Three lines, boss. Make sure you give us the team to remove, then the team to add.") await msg.channel.send("Three lines, boss. Make sure you give us the team to remove, then the team to add.")
return return
if team_add.name == team_del.name:
await msg.channel.send("Quit being cheeky. The teams have to be different.")
return
if team_del is None or team_add is None: if team_del is None or team_add is None:
await msg.channel.send("We couldn't find one or both of those teams, boss. Try again.") await msg.channel.send("We couldn't find one or both of those teams, boss. Try again.")
return return
subleague, division = league.find_team(team_del) subleague, division = league.find_team(team_del)
if subleague is None or division is None: if subleague is None or division is None:
await msg.channel.send("That first team isn't in that league, chief. So, that's good, right?") await msg.channel.send("That first team isn't in that league, chief. So, that's good, right?")
return return
if league.find_team(team_add)[0] is not None:
await msg.channel.send("That second team is already in that league, chief. No doubles.")
return
for index in range(0, len(league.league[subleague][division])): for index in range(0, len(league.league[subleague][division])):
if league.league[subleague][division][index].name == team_del.name: if league.league[subleague][division][index].name == team_del.name:
league.league[subleague][division].pop(index) league.league[subleague][division].pop(index)