#paginator
1 messages · Page 1 of 1 (latest)
You can use a custom view/custom button so yeah I think
Well you might have to edit each time the paginator button to put ur view so maybe a dropdown will be better with the emoji as product, Name and description
Thank you, i roughly understood
Sorry my English is not the best but if u need more explanation ask me I will try my best
Okay, thanks, if you need help I'll contact you. I don’t know English well either, I use a translator
class SelectSpecial(discord.ui.Button):
def __init__(self, bot, label):
super().__init__(
label=label,
emoji="📢",
custom_id="offers_select",
style=discord.ButtonStyle.red
)
self.bot = bot
async def callback(self, interaction: discord.Interaction):
pool = await aiomysql.create_pool(host=config["host"], port=config["port"], user=config["user"], password=config['password'], db=config["db"])
async with pool.acquire() as conn:
async with conn.cursor() as cursor:
await cursor.execute("SELECT lang FROM users WHERE user_id = %s",(interaction.user.id,))
result = await cursor.fetchone()
lang = result[0]
await cursor.execute("SELECT * FROM special_offers")
result = await cursor.fetchall()
view = discord.ui.View(timeout=None)
view.add_item(BackToAdmin(self.bot, label="Назад" if lang == 'ru' else 'Back'))
view.add_item(CreateSpecialOffers(self.bot, label="Создать товар" if lang == 'ru' else 'Create product'))
options = []
pages_list = []
page_size = 2
if len(result) > page_size:
for i, row in enumerate(result):
id = row[0]
name = row[1] if lang == 'ru' else row[2]
emoji = row[4]
description = row[5] if lang == 'ru' else row[6]
status = row[11]
if len(description) > 98:
description = description[:98] + "…"
options.append(discord.SelectOption(label=name, emoji=emoji, description=description, value=str(id)))
if (i + 1) % page_size == 0 or i + 1 == len(result):
pages_list.append(options)
options = []
paginator = pages.Paginator(pages=pages_list, use_default_buttons=False, loop_pages=True)
paginator.add_button(pages.PaginatorButton('prev', emoji="⬅️", style=discord.ButtonStyle.red))
paginator.add_button(pages.PaginatorButton('next', emoji="➡️", style=discord.ButtonStyle.green))
paginator.add_button(pages.PaginatorButton('page_indicator', style=discord.ButtonStyle.gray, disabled=True))
Still, I need your help. Here is my example when, the point is that if the number of products exceeds 2, then the paginator appears, my products are in the selector, and when moving through the pages of the paginator, the selector needs to change
Current error: all items must be embeds or files.
What I was meaning is use a select menu, when the user select the time you edit the embed with the other product. And so not use paginator but select menu
Sorry, I didn't quite understand what you mean
like not using paginator but a dropdown