Run formatter

This commit is contained in:
2022-03-10 16:39:25 +01:00
parent ab1ce1dcd6
commit 92bf5fd504

View File

@ -39,7 +39,9 @@ def calc_countdown(job) -> str:
Returns:
str: Returns days, hours and minutes till reminder. Returns "Failed to calculate time" if no job is found.
"""
trigger_time = job.trigger.run_date if type(job.trigger) is DateTrigger else job.next_run_time
trigger_time = (
job.trigger.run_date if type(job.trigger) is DateTrigger else job.next_run_time
)
# Get_job() returns None when it can't find a job with that id.
if trigger_time is None:
@ -74,7 +76,9 @@ async def on_slash_command_error(ctx: SlashContext, ex: Exception):
https://discord-py-slash-command.readthedocs.io/en/latest/discord_slash.error.html
"""
logging.error(f'Error occurred during the execution of "/{ctx.name} {ctx.subcommand_name}" by {ctx.author}: {ex}')
logging.error(
f'Error occurred during the execution of "/{ctx.name} {ctx.subcommand_name}" by {ctx.author}: {ex}'
)
if ex == RequestFailure:
message = f"Request to Discord API failed: {ex}"
elif ex == IncorrectFormat:
@ -167,7 +171,9 @@ async def command_modify(ctx: SlashContext, time_or_message: str):
if time_or_message == "message":
await ctx.channel.send("Type the new message. Type Exit to exit.")
try:
response_new_message = await bot.wait_for("message", check=check, timeout=60)
response_new_message = await bot.wait_for(
"message", check=check, timeout=60
)
except TimeoutError:
return await ctx.channel.send("Timed out, try again.")
if response_new_message.clean_content == "Exit":
@ -186,7 +192,9 @@ async def command_modify(ctx: SlashContext, time_or_message: str):
else:
await ctx.channel.send("Type the new date. Type Exit to exit.")
try:
response_new_date = await bot.wait_for("message", check=check, timeout=60)
response_new_date = await bot.wait_for(
"message", check=check, timeout=60
)
except TimeoutError:
return await ctx.channel.send("Timed out, try again.")
if response_new_date.clean_content == "Exit":
@ -202,9 +210,13 @@ async def command_modify(ctx: SlashContext, time_or_message: str):
# FIXME: Fix mypy error
remove_timezone_from_date = parsed_date.strftime("%Y-%m-%d %H:%M:%S") # type: ignore[union-attr]
job = scheduler.reschedule_job(job_from_dict, run_date=remove_timezone_from_date)
job = scheduler.reschedule_job(
job_from_dict, run_date=remove_timezone_from_date
)
remove_timezone_from_date_old = job.trigger.run_date.strftime("%Y-%m-%d %H:%M")
remove_timezone_from_date_old = job.trigger.run_date.strftime(
"%Y-%m-%d %H:%M"
)
the_final_countdown_new = calc_countdown(job_from_dict)
msg += (
f"**Old date**: {remove_timezone_from_date_old} (in {the_final_countdown_old})\n"
@ -231,7 +243,9 @@ async def remind_remove(ctx: SlashContext):
await ctx.send(f"{ctx.guild.name} has no reminders.")
else:
await ctx.send(embed=list_embed)
await ctx.channel.send("Type the corresponding number to the reminder you wish to remove. Type Exit to exit.")
await ctx.channel.send(
"Type the corresponding number to the reminder you wish to remove. Type Exit to exit."
)
# Only check for response from the original user and in the correct channel
def check(m):
@ -248,7 +262,9 @@ async def remind_remove(ctx: SlashContext):
if int(response_message.clean_content) == num:
job = scheduler.get_job(job_from_dict)
if job is None:
await ctx.channel.send(f"No reminder with that ID ({job_from_dict}).")
await ctx.channel.send(
f"No reminder with that ID ({job_from_dict})."
)
return
channel_id = job.kwargs.get("channel_id")
@ -378,7 +394,9 @@ async def remind_pause(ctx: SlashContext):
await ctx.send(f"{ctx.guild.name} has no reminders.")
else:
await ctx.send(embed=list_embed)
await ctx.channel.send("Type the corresponding number to the reminder you wish to pause. Type Exit to exit.")
await ctx.channel.send(
"Type the corresponding number to the reminder you wish to pause. Type Exit to exit."
)
# Only check for response from the original user and in the correct channel
def check(m):
@ -440,7 +458,9 @@ async def remind_resume(ctx: SlashContext):
await ctx.send(f"{ctx.guild.name} has no reminders.")
else:
await ctx.send(embed=list_embed)
await ctx.channel.send("Type the corresponding number to the reminder you wish to pause. Type Exit to exit.")
await ctx.channel.send(
"Type the corresponding number to the reminder you wish to pause. Type Exit to exit."
)
# Only check for response from the original user and in the correct channel
def check(m):