Run formatter
This commit is contained in:
@ -39,7 +39,9 @@ def calc_countdown(job) -> str:
|
|||||||
Returns:
|
Returns:
|
||||||
str: Returns days, hours and minutes till reminder. Returns "Failed to calculate time" if no job is found.
|
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.
|
# Get_job() returns None when it can't find a job with that id.
|
||||||
if trigger_time is None:
|
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
|
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:
|
if ex == RequestFailure:
|
||||||
message = f"Request to Discord API failed: {ex}"
|
message = f"Request to Discord API failed: {ex}"
|
||||||
elif ex == IncorrectFormat:
|
elif ex == IncorrectFormat:
|
||||||
@ -167,7 +171,9 @@ async def command_modify(ctx: SlashContext, time_or_message: str):
|
|||||||
if time_or_message == "message":
|
if time_or_message == "message":
|
||||||
await ctx.channel.send("Type the new message. Type Exit to exit.")
|
await ctx.channel.send("Type the new message. Type Exit to exit.")
|
||||||
try:
|
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:
|
except TimeoutError:
|
||||||
return await ctx.channel.send("Timed out, try again.")
|
return await ctx.channel.send("Timed out, try again.")
|
||||||
if response_new_message.clean_content == "Exit":
|
if response_new_message.clean_content == "Exit":
|
||||||
@ -186,7 +192,9 @@ async def command_modify(ctx: SlashContext, time_or_message: str):
|
|||||||
else:
|
else:
|
||||||
await ctx.channel.send("Type the new date. Type Exit to exit.")
|
await ctx.channel.send("Type the new date. Type Exit to exit.")
|
||||||
try:
|
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:
|
except TimeoutError:
|
||||||
return await ctx.channel.send("Timed out, try again.")
|
return await ctx.channel.send("Timed out, try again.")
|
||||||
if response_new_date.clean_content == "Exit":
|
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
|
# FIXME: Fix mypy error
|
||||||
remove_timezone_from_date = parsed_date.strftime("%Y-%m-%d %H:%M:%S") # type: ignore[union-attr]
|
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)
|
the_final_countdown_new = calc_countdown(job_from_dict)
|
||||||
msg += (
|
msg += (
|
||||||
f"**Old date**: {remove_timezone_from_date_old} (in {the_final_countdown_old})\n"
|
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.")
|
await ctx.send(f"{ctx.guild.name} has no reminders.")
|
||||||
else:
|
else:
|
||||||
await ctx.send(embed=list_embed)
|
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
|
# Only check for response from the original user and in the correct channel
|
||||||
def check(m):
|
def check(m):
|
||||||
@ -248,7 +262,9 @@ async def remind_remove(ctx: SlashContext):
|
|||||||
if int(response_message.clean_content) == num:
|
if int(response_message.clean_content) == num:
|
||||||
job = scheduler.get_job(job_from_dict)
|
job = scheduler.get_job(job_from_dict)
|
||||||
if job is None:
|
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
|
return
|
||||||
|
|
||||||
channel_id = job.kwargs.get("channel_id")
|
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.")
|
await ctx.send(f"{ctx.guild.name} has no reminders.")
|
||||||
else:
|
else:
|
||||||
await ctx.send(embed=list_embed)
|
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
|
# Only check for response from the original user and in the correct channel
|
||||||
def check(m):
|
def check(m):
|
||||||
@ -440,7 +458,9 @@ async def remind_resume(ctx: SlashContext):
|
|||||||
await ctx.send(f"{ctx.guild.name} has no reminders.")
|
await ctx.send(f"{ctx.guild.name} has no reminders.")
|
||||||
else:
|
else:
|
||||||
await ctx.send(embed=list_embed)
|
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
|
# Only check for response from the original user and in the correct channel
|
||||||
def check(m):
|
def check(m):
|
||||||
|
Reference in New Issue
Block a user