game stuff

This commit is contained in:
NikolajDanger
2021-09-30 14:05:50 +02:00
parent 5330a51fe0
commit cbf2ca765e
12 changed files with 538 additions and 551 deletions

View File

@ -15,6 +15,7 @@ from discord.ext import commands # Used to compare errors with command
from discord_slash.context import SlashContext, ComponentContext
from gwendolyn.utils.util_functions import decode_id
from gwendolyn.exceptions import InvalidInteraction
class EventHandler():
@ -64,7 +65,8 @@ class EventHandler():
async def on_component(self, ctx: ComponentContext):
info = decode_id(ctx.custom_id)
self.bot.log(f"Component action with info {info}")
channel = ctx.origin_message.channel
channel = ctx.channel
author = str(ctx.author_id)
if info[0].lower() == "plex":
if info[1].lower() == "movie":
@ -73,25 +75,29 @@ class EventHandler():
info[2],
not isinstance(channel, discord.DMChannel)
)
return
elif info[1].lower() == "show":
if info[1].lower() == "show":
await self.bot.other.plex.add_show(
ctx.origin_message,
info[2],
not isinstance(channel, discord.DMChannel)
)
return
elif info[0].lower() == "hangman":
if str(ctx.author_id) == info[2]:
if info[1].lower() == "guess":
await self.bot.games.hangman.guess(ctx, *info[3:])
elif info[1].lower() == "end":
await self.bot.games.hangman.stop(ctx, *info[3:])
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":
await self.bot.games.hangman.stop(ctx, *info[3:])
return
elif info[0].lower() == "connectfour":
connect_four = self.bot.games.connect_four
if info[1].lower() == "place" and str(ctx.author_id) == info[2]:
params = [
if info[1].lower() == "place" and author == info[2]:
await connect_four.place_piece(
ctx,
info[3],
int(info[4]),
@ -99,14 +105,20 @@ class EventHandler():
int(info[7]),
ctx.author_id,
int(info[8])
]
await connect_four.place_piece(*params)
if info[1].lower() == "end":
if str(ctx.author_id) in [info[2], info[3]]:
params = [
ctx, [int(info[2]), int(info[3])], info[4], info[5]
]
await connect_four.surrender(*params)
)
return
if 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
elif info[0].lower() == "blackjack":
await self.bot.games.blackjack.decode_interaction(ctx, info[1:])
return
raise InvalidInteraction(ctx.custom_id, info)