Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add paginator interaction_check + remove inventory max_concurrency #284

Merged
merged 5 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion bot/cogs/commands/econ.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ async def inventory_boiler(self, ctx: Ctx, user: discord.User = None):
return True, user

@commands.group(name="inventory", aliases=["inv", "items"], case_insensitive=True)
@commands.max_concurrency(3, per=commands.BucketType.user, wait=False)
@commands.guild_only()
@commands.cooldown(2, 2, commands.BucketType.user)
async def inventory(self, ctx: Ctx):
Expand Down
9 changes: 8 additions & 1 deletion bot/cogs/core/paginator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@


class PaginatorView(discord.ui.View):
def __init__(self, get_page, page_count, timeout):
def __init__(self, author, get_page, page_count, timeout):
Iapetus-11 marked this conversation as resolved.
Show resolved Hide resolved
super().__init__(timeout=timeout)

self._author = author
self._page = 0
self._page_count = page_count
self._get_page = get_page

async def interaction_check(self, interaction: discord.Interaction) -> bool:
if interaction.user != self._author:
return False
return True

@discord.ui.button(emoji="⏪", style=discord.ButtonStyle.gray)
async def btn_first(self, interaction: discord.Interaction, button: discord.ui.Button):
self._page = 0
Expand Down Expand Up @@ -89,6 +95,7 @@ async def paginate_embed(
return await ctx.reply(embed=embed, mention_author=False)

view = PaginatorView(
author=ctx.author,
get_page=lambda page: self._get_page(get_page, page),
page_count=page_count,
timeout=timeout,
Expand Down
Loading