Skip to content

Commit

Permalink
Update error
Browse files Browse the repository at this point in the history
  • Loading branch information
Saverio976 committed Sep 19, 2024
1 parent c968187 commit b59121f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
13 changes: 6 additions & 7 deletions worldtimezone/extensions/world_clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,20 @@ async def convertIt(
return
message = ""
user_info = ctx.bot.d.data.get_member(ctx.guild_id, ctx.user.id)
if "tz" not in user_info:
if user_info is None or user_info.tz == "":
await ctx.respond("Please set your timezone first")
return
now = datetime.datetime(year=year, month=month, day=day, hour=hour, minute=minute)
if timezone is None:
now = pytz.timezone(user_info["tz"]).localize(now)
now = pytz.timezone(user_info.tz).localize(now)
else:
now = pytz.timezone(timezone).localize(now)
for u in ctx.bot.d.data.get_members_list(ctx.guild_id):
member_info = ctx.bot.d.data.get_member(ctx.guild_id, u)
if "tz" in member_info:
for member_info in ctx.bot.d.data.get_members_list(ctx.guild_id):
if member_info.tz != "":
user_ = ctx.bot.cache.get_member(ctx.guild_id, int(u))
new_tz = pytz.timezone(member_info["tz"])
new_tz = pytz.timezone(member_info.tz)
new_now = now.astimezone(new_tz)
message += f"**{user_.display_name}**: {new_now}\n"
message += f"**{user_.display_name}**: {new_now} [{member_info.tz}]\n"
await ctx.respond(message)


Expand Down
3 changes: 2 additions & 1 deletion worldtimezone/extensions/world_clock_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ def get_member(self, guild_id, user_id) -> Optional[DBMember]:
try:
return (
DBMember.select()
.join(DBGuild)
.where(
(DBMember.discord_id == user_id)
& (DBMember.guild.discord_id == guild_id)
& (DBGuild.discord_id == guild_id)
)
.get()
)
Expand Down

0 comments on commit b59121f

Please sign in to comment.