Fix minor bugs in LTX
This commit is contained in:
parent
cc5456457b
commit
eb4364ce03
1 changed files with 24 additions and 14 deletions
|
@ -27,17 +27,20 @@ class EventCog(Extension):
|
|||
|
||||
async def is_dipshit(self, ctx: InteractionContext) -> bool:
|
||||
"""Checks if author is bot owner."""
|
||||
return dipshit_id in ctx.author._role_ids
|
||||
guild = await self.bot.fetch_guild(520021794380447745)
|
||||
member = await guild.fetch_member(ctx.author.id)
|
||||
return member and dipshit_id in member._role_ids
|
||||
|
||||
ltx = SlashCommand(name="ltx", description="LTX Meetup management", scopes=[520021794380447745])
|
||||
ltx = SlashCommand(name="ltx", description="LTX Meetup management")
|
||||
|
||||
@ltx.subcommand(sub_cmd_name="register", sub_cmd_description="Register for LTX")
|
||||
@slash_option(name="going", description="Are you going?", opt_type=OptionTypes.BOOLEAN)
|
||||
async def _ltx_register(self, ctx: InteractionContext, going: bool) -> None:
|
||||
event = await Event.find_one(q(user=ctx.author.id, event="ltx"))
|
||||
event = await Event.find_one(q(user=ctx.author.id, event_name="ltx"))
|
||||
if not event:
|
||||
event = Event(user=ctx.author.id, going=going)
|
||||
event = Event(user=ctx.author.id, going=going, event_name="ltx")
|
||||
event.going = going
|
||||
await event.commit()
|
||||
msg = "going" if going else "not going"
|
||||
await ctx.send(f"Registration updated! You are now {msg}", ephemeral=True)
|
||||
|
||||
|
@ -45,15 +48,15 @@ class EventCog(Extension):
|
|||
@slash_option(
|
||||
name="user", description="User to show", opt_type=OptionTypes.USER, required=False
|
||||
)
|
||||
async def _ltx_show(self, ctx: InteractionContext, user: Member) -> None:
|
||||
async def _ltx_show(self, ctx: InteractionContext, user: Member = None) -> None:
|
||||
user = user or ctx.author
|
||||
event = await Event.find_one(q(user=user.id, event="ltx"))
|
||||
event = await Event.find_one(q(user=user.id, event_name="ltx"))
|
||||
if not event:
|
||||
await ctx.send("That user hasn't registered", ephemeral=False)
|
||||
await ctx.send("That user hasn't registered", ephemeral=True)
|
||||
return
|
||||
|
||||
if not event.going:
|
||||
await ctx.send("That user isn't going", ephemeral=False)
|
||||
await ctx.send("That user isn't going", ephemeral=True)
|
||||
return
|
||||
|
||||
fields = []
|
||||
|
@ -112,9 +115,9 @@ class EventCog(Extension):
|
|||
to_airport: str,
|
||||
flight: str,
|
||||
) -> None:
|
||||
event = await Event.find_one(q(user=ctx.author.id, event="ltx"))
|
||||
event = await Event.find_one(q(user=ctx.author.id, event_name="ltx"))
|
||||
if not event:
|
||||
event = Event(user=ctx.author.id, event="ltx", going=True)
|
||||
event = Event(user=ctx.author.id, event_name="ltx", going=True)
|
||||
|
||||
base_settings = {
|
||||
"PREFER_DATES_FROM": "future",
|
||||
|
@ -156,6 +159,8 @@ class EventCog(Extension):
|
|||
event.before_departure_time = departure
|
||||
event.before_flight = f"{from_airport} -> {to_airport} {flight}"
|
||||
|
||||
await event.commit()
|
||||
|
||||
dts = int(departure.timestamp())
|
||||
ats = int(arrival.timestamp())
|
||||
|
||||
|
@ -166,7 +171,7 @@ class EventCog(Extension):
|
|||
|
||||
embed = build_embed(
|
||||
title="Your Pre-LTX Flight Information",
|
||||
description=f"🛫 {from_airport} -> {to_airport} 🛬",
|
||||
description=f"🛫 {from_airport} -> {to_airport} {flight} 🛬",
|
||||
fields=fields,
|
||||
)
|
||||
embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.display_avatar.url)
|
||||
|
@ -201,9 +206,9 @@ class EventCog(Extension):
|
|||
to_airport: str,
|
||||
flight: str,
|
||||
) -> None:
|
||||
event = await Event.find_one(q(user=ctx.author.id, event="ltx"))
|
||||
event = await Event.find_one(q(user=ctx.author.id, event_name="ltx"))
|
||||
if not event:
|
||||
event = Event(user=ctx.author.id, event="ltx", going=True)
|
||||
event = Event(user=ctx.author.id, event_name="ltx", going=True)
|
||||
|
||||
base_settings = {
|
||||
"PREFER_DATES_FROM": "future",
|
||||
|
@ -245,6 +250,8 @@ class EventCog(Extension):
|
|||
event.after_departure_time = departure
|
||||
event.after_flight = f"{from_airport} -> {to_airport} {flight}"
|
||||
|
||||
await event.commit()
|
||||
|
||||
dts = int(departure.timestamp())
|
||||
ats = int(arrival.timestamp())
|
||||
|
||||
|
@ -255,9 +262,12 @@ class EventCog(Extension):
|
|||
|
||||
embed = build_embed(
|
||||
title="Your Post-LTX Flight Information",
|
||||
description=f"🛫 {from_airport} -> {to_airport} 🛬",
|
||||
description=f"🛫 {from_airport} -> {to_airport} {flight} 🛬",
|
||||
fields=fields,
|
||||
)
|
||||
embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.display_avatar.url)
|
||||
|
||||
await ctx.send(embeds=embed)
|
||||
|
||||
def setup(client):
|
||||
EventCog(client)
|
||||
|
|
Loading…
Add table
Reference in a new issue