remove message and context arguments from reaction message callback

pull/1/head
qwewqa 4 years ago
parent 34565ddff0
commit f56064f1e1
  1. 2
      miyu_bot/commands/cogs/card.py
  2. 10
      miyu_bot/commands/common/reaction_message.py

@ -58,7 +58,7 @@ class Card(commands.Cog):
index = 0
limit_break = 1
async def callback(emoji, _ctx, _message):
async def callback(emoji):
nonlocal index
nonlocal limit_break
try:

@ -15,7 +15,7 @@ async def run_tabbed_message(ctx: Context, emojis: List[AnyEmoji], embeds: List[
message = await ctx.send(files=files, embed=embeds[starting_index])
async def callback(emoji, _ctx, _message):
async def callback(emoji):
await message.edit(embed=embeds[emojis.index(emoji)])
await run_reaction_message(ctx, message, emojis, callback, timeout)
@ -28,7 +28,7 @@ async def run_dynamically_paged_message(ctx: Context, embed_generator: Callable[
message = await ctx.send(embed=embed_generator(0))
async def callback(emoji, _ctx, _message):
async def callback(emoji):
if emoji == left_arrow:
new_embed = embed_generator(-1)
elif emoji == right_arrow:
@ -94,7 +94,7 @@ async def run_paged_message(ctx: Context, base_embed: discord.Embed, content: Li
index = 0
async def callback(emoji, _ctx, _message):
async def callback(emoji):
nonlocal index
start_index = index
if emoji == double_left_arrow:
@ -114,7 +114,7 @@ async def run_paged_message(ctx: Context, base_embed: discord.Embed, content: Li
async def run_reaction_message(ctx: Context, message: Message, emojis: List[AnyEmoji],
callback: Callable[[AnyEmoji, Context, Message], Awaitable[None]], timeout=300):
callback: Callable[[AnyEmoji], Awaitable[None]], timeout=300):
for emoji in emojis:
await message.add_reaction(emoji)
@ -124,7 +124,7 @@ async def run_reaction_message(ctx: Context, message: Message, emojis: List[AnyE
while True:
try:
reaction, user = await ctx.bot.wait_for('reaction_add', timeout=timeout, check=check)
await callback(reaction.emoji, ctx, message)
await callback(reaction.emoji)
await message.remove_reaction(reaction, user)
except asyncio.TimeoutError:
for emoji in emojis:

Loading…
Cancel
Save