Strip spaces from all lines, and add some fallback messages if some commands are run without arguments
This commit is contained in:
parent
41c924a9ef
commit
781ded0984
|
@ -62,6 +62,9 @@ async def on_message(msg):
|
||||||
if not command_b:
|
if not command_b:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# clear trailing spaces from each line
|
||||||
|
command = "\n".join([line.strip() for line in command.split("\n")])
|
||||||
|
|
||||||
if msg.author.id in config()["owners"] and command == "introduce":
|
if msg.author.id in config()["owners"] and command == "introduce":
|
||||||
await introduce(msg.channel)
|
await introduce(msg.channel)
|
||||||
|
|
||||||
|
@ -100,7 +103,7 @@ async def on_message(msg):
|
||||||
except:
|
except:
|
||||||
await msg.channel.send("Something went wrong. Tell xvi.")
|
await msg.channel.send("Something went wrong. Tell xvi.")
|
||||||
|
|
||||||
elif command == "showidol":
|
elif command.startswith("showidol"):
|
||||||
try:
|
try:
|
||||||
player_json = db.get_user_player(msg.author)
|
player_json = db.get_user_player(msg.author)
|
||||||
embed=build_star_embed(player_json)
|
embed=build_star_embed(player_json)
|
||||||
|
@ -110,12 +113,15 @@ async def on_message(msg):
|
||||||
await msg.channel.send("We can't find your idol. Looked everywhere, too.")
|
await msg.channel.send("We can't find your idol. Looked everywhere, too.")
|
||||||
|
|
||||||
elif command.startswith("showplayer"):
|
elif command.startswith("showplayer"):
|
||||||
|
if " " in command:
|
||||||
player_name = json.loads(ono.get_stats(command.split(" ",1)[1]))
|
player_name = json.loads(ono.get_stats(command.split(" ",1)[1]))
|
||||||
await msg.channel.send(embed=build_star_embed(player_name))
|
await msg.channel.send(embed=build_star_embed(player_name))
|
||||||
|
else:
|
||||||
|
await msg.channel.send("If you wanna hear about anyone in particular, I'm gonna need a name.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
elif command.startswith("startgame\n"):
|
elif command.startswith("startgame"):
|
||||||
if len(gamesarray) > 45:
|
if len(gamesarray) > 45:
|
||||||
await msg.channel.send("We're running 45 games and we doubt Discord will be happy with any more. These edit requests don't come cheap.")
|
await msg.channel.send("We're running 45 games and we doubt Discord will be happy with any more. These edit requests don't come cheap.")
|
||||||
return
|
return
|
||||||
|
@ -166,32 +172,42 @@ async def on_message(msg):
|
||||||
game_task = asyncio.create_task(setup_game(msg.channel, msg.author, games.game(msg.author.name, games.team(), games.team(), length=inningmax)))
|
game_task = asyncio.create_task(setup_game(msg.channel, msg.author, games.game(msg.author.name, games.team(), games.team(), length=inningmax)))
|
||||||
await game_task
|
await game_task
|
||||||
|
|
||||||
elif command.startswith("saveteam\n"):
|
elif command.startswith("saveteam"):
|
||||||
|
if "\n" in command:
|
||||||
if db.get_team(command.split("\n",1)[1].split("\n")[0]) == None:
|
if db.get_team(command.split("\n",1)[1].split("\n")[0]) == None:
|
||||||
save_task = asyncio.create_task(save_team_batch(msg, command))
|
save_task = asyncio.create_task(save_team_batch(msg, command))
|
||||||
await save_task
|
await save_task
|
||||||
else:
|
else:
|
||||||
name = command.split('\n',1)[1].split('\n')[0]
|
name = command.split('\n',1)[1].split('\n')[0]
|
||||||
await msg.channel.send(f"{name} already exists. Try a new name, maybe?")
|
await msg.channel.send(f"{name} already exists. Try a new name, maybe?")
|
||||||
|
else:
|
||||||
|
await msg.channel.send("The Null Team's already in the League, chief.")
|
||||||
|
|
||||||
elif command.startswith("showteam"):
|
elif command.startswith("showteam"):
|
||||||
|
if " " in command:
|
||||||
team = games.get_team(command.split(" ",1)[1])
|
team = games.get_team(command.split(" ",1)[1])
|
||||||
if team is not None:
|
if team is not None:
|
||||||
await msg.channel.send(embed=build_team_embed(team))
|
await msg.channel.send(embed=build_team_embed(team))
|
||||||
else:
|
else:
|
||||||
await msg.channel.send("Can't find that team, boss. Typo?")
|
await msg.channel.send("Can't find that team, boss. Typo?")
|
||||||
|
else:
|
||||||
|
await msg.channel.send("I need a team name to look 'em up, boss. If you want to gaze from up high, you might like the 'showallteams' command.")
|
||||||
|
|
||||||
elif command == ("showallteams"):
|
elif command == ("showallteams"):
|
||||||
list_task = asyncio.create_task(team_pages(msg, games.get_all_teams()))
|
list_task = asyncio.create_task(team_pages(msg, games.get_all_teams()))
|
||||||
await list_task
|
await list_task
|
||||||
|
|
||||||
elif command.startswith("searchteams"):
|
elif command.startswith("searchteams"):
|
||||||
|
if " " in command:
|
||||||
search_term = command.split("searchteams ",1)[1]
|
search_term = command.split("searchteams ",1)[1]
|
||||||
if len(search_term) > 30:
|
if len(search_term) > 30:
|
||||||
await msg.channel.send("Team names can't even be that long, chief. Try something shorter.")
|
await msg.channel.send("Team names can't even be that long, chief. Try something shorter.")
|
||||||
return
|
return
|
||||||
list_task = asyncio.create_task(team_pages(msg, games.search_team(search_term), search_term=search_term))
|
list_task = asyncio.create_task(team_pages(msg, games.search_team(search_term), search_term=search_term))
|
||||||
await list_task
|
await list_task
|
||||||
|
else:
|
||||||
|
await msg.channel.send("Gotta say what you're looking for if you want to search.")
|
||||||
|
|
||||||
|
|
||||||
elif command == "credit":
|
elif command == "credit":
|
||||||
await msg.channel.send("Our avatar was graciously provided to us, with permission, by @HetreaSky on Twitter.")
|
await msg.channel.send("Our avatar was graciously provided to us, with permission, by @HetreaSky on Twitter.")
|
||||||
|
|
Loading…
Reference in a new issue