fixing blackjack and improving lookup

This commit is contained in:
Nikolaj
2022-01-28 11:33:47 +01:00
parent cbf2ca765e
commit 05cd5831e1
10 changed files with 219 additions and 160 deletions

View File

@ -63,6 +63,7 @@ class EventHandler():
self.bot.log(log_message, str(ctx.channel_id), level=25)
async def on_component(self, ctx: ComponentContext):
"""Handle component interaction."""
info = decode_id(ctx.custom_id)
self.bot.log(f"Component action with info {info}")
channel = ctx.channel
@ -77,23 +78,22 @@ class EventHandler():
)
return
if info[1].lower() == "show":
elif info[1].lower() == "show":
await self.bot.other.plex.add_show(
ctx.origin_message,
info[2],
not isinstance(channel, discord.DMChannel)
)
return
else:
raise InvalidInteraction(ctx.custom_id, info)
elif info[0].lower() == "hangman" and author == info[2]:
if info[1].lower() == "guess":
await self.bot.games.hangman.guess(ctx, *info[3:])
return
if info[1].lower() == "end":
elif info[1].lower() == "end":
await self.bot.games.hangman.stop(ctx, *info[3:])
return
else:
raise InvalidInteraction(ctx.custom_id, info)
elif info[0].lower() == "connectfour":
connect_four = self.bot.games.connect_four
if info[1].lower() == "place" and author == info[2]:
@ -106,19 +106,16 @@ class EventHandler():
ctx.author_id,
int(info[8])
)
return
if info[1].lower() == "end" and author in [info[2], info[3]]:
elif info[1].lower() == "end" and author in [info[2], info[3]]:
await connect_four.surrender(
ctx, [int(info[2]), int(info[3])], info[4], info[5]
)
return
else:
raise InvalidInteraction(ctx.custom_id, info)
elif info[0].lower() == "blackjack":
await self.bot.games.blackjack.decode_interaction(ctx, info[1:])
return
raise InvalidInteraction(ctx.custom_id, info)
else:
raise InvalidInteraction(ctx.custom_id, info)