Remove self.end_paginator and #type: ignore comments

This commit is contained in:
2022-10-26 01:50:33 +02:00
parent 1dc5a0fd94
commit f44f0a31c3

View File

@ -113,7 +113,7 @@ def create_pages(ctx) -> list[Page]:
Page( Page(
embeds=embed, embeds=embed,
title=title, title=title,
components=ActionRow(components=components), # type: ignore components=ActionRow(components=components),
callback=callback, callback=callback,
position=RowPosition.BOTTOM, position=RowPosition.BOTTOM,
) )
@ -124,7 +124,7 @@ def create_pages(ctx) -> list[Page]:
async def callback(self: Paginator, ctx: ComponentContext): async def callback(self: Paginator, ctx: ComponentContext):
"""Callback for the paginator.""" """Callback for the paginator."""
job_id = self.component_ctx.message.embeds[0].title # type: ignore job_id = self.component_ctx.message.embeds[0].title
job = scheduler.get_job(job_id) job = scheduler.get_job(job_id)
if job is None: if job is None:
@ -134,7 +134,7 @@ async def callback(self: Paginator, ctx: ComponentContext):
old_message = job.kwargs.get("message") old_message = job.kwargs.get("message")
components = [ components = [
interactions.TextInput( # type: ignore interactions.TextInput(
style=interactions.TextStyleType.PARAGRAPH, style=interactions.TextStyleType.PARAGRAPH,
label="New message", label="New message",
custom_id="new_message", custom_id="new_message",
@ -148,7 +148,7 @@ async def callback(self: Paginator, ctx: ComponentContext):
trigger_time = job.trigger.run_date trigger_time = job.trigger.run_date
job_type = "normal" job_type = "normal"
components.append( components.append(
interactions.TextInput( # type: ignore interactions.TextInput(
style=interactions.TextStyleType.SHORT, style=interactions.TextStyleType.SHORT,
label="New date, Can be human readable or ISO8601", label="New date, Can be human readable or ISO8601",
custom_id="new_date", custom_id="new_date",
@ -163,28 +163,24 @@ async def callback(self: Paginator, ctx: ComponentContext):
job_type = "cron/interval" job_type = "cron/interval"
if ctx.custom_id == "edit": if ctx.custom_id == "edit":
await self.end_paginator()
modal = interactions.Modal( modal = interactions.Modal(
title=f"Edit {job_type} reminder.", title=f"Edit {job_type} reminder.",
custom_id="edit_modal", custom_id="edit_modal",
components=components, # type: ignore components=components,
) )
await ctx.popup(modal) await ctx.popup(modal)
elif ctx.custom_id == "pause": elif ctx.custom_id == "pause":
await self.end_paginator()
# TODO: Add unpause button if user paused the wrong job # TODO: Add unpause button if user paused the wrong job
scheduler.pause_job(job_id) scheduler.pause_job(job_id)
await ctx.send(f"Job {job_id} paused.") await ctx.send(f"Job {job_id} paused.")
elif ctx.custom_id == "unpause": elif ctx.custom_id == "unpause":
await self.end_paginator()
# TODO: Add pause button if user unpauses the wrong job # TODO: Add pause button if user unpauses the wrong job
scheduler.resume_job(job_id) scheduler.resume_job(job_id)
await ctx.send(f"Job {job_id} unpaused.") await ctx.send(f"Job {job_id} unpaused.")
elif ctx.custom_id == "remove": elif ctx.custom_id == "remove":
await self.end_paginator()
# TODO: Add recreate button if user removed the wrong job # TODO: Add recreate button if user removed the wrong job
scheduler.remove_job(job_id) scheduler.remove_job(job_id)
await ctx.send( await ctx.send(