async def button_callback(interaction: Interaction):
nonlocal number_operation
if interaction.data["custom_id"] == "первый" and number_operation > 0:
number_operation -= 1
elif interaction.data["custom_id"] == "последний" and number_operation < count_operation - 1:
number_operation += 1
new_embed = create_embed(size_embed, roles_info, number_operation)
await interaction.response.edit_message(embed=new_embed)
previous_button = Button(label="Предыдущий", style=ButtonStyle.primary, custom_id="первый")
previous_button.callback = button_callback
next_button = Button(label="Следующий", style=ButtonStyle.primary, custom_id="последний")
next_button.callback = button_callback
view = View()
view.add_item(previous_button)
view.add_item(next_button)
await inter.response.send_message(embed=embed, view=view)
def get_id_role(level):
cursor.execute("""
SELECT id_role FROM levels
WHERE level = ?
""", (level,))
result = cursor.fetchone()
if result:
return result[0]
return None