我想在产品商店达到某个边界时禁用该按钮,并且您不能再单击“下一页”或“上一页”按钮。但由于无法将实例变量传递给装饰器,因此我无法比较值并将它们传递给@nextcord.ui.button。你能帮我解决这个问题吗?这是我的密码:
import nextcord
from nextcord.ext import commands
from SupportClasses import BuildShop as bd
from SupportClasses import Build
class ShopBuildings(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.command()
async def ShopBuild(self, ctx, numberPage=1):
shopBuildings = bd.getBuildShop()
view = ShopPages(shopBuildings, int(numberPage))
await ctx.send(embed=createEmded('ShopBuildings', shopBuildings[int(numberPage)-1], view=view))
class ShopPages(nextcord.ui.View):
def __init__(self, shop, numberPage):
super().__init__()
self.__shop = shop
self.__numberPage = numberPage-1
@nextcord.ui.button(label='Past Page', style=nextcord.ButtonStyle.primary)
async def BackPage(self, button: nextcord.ui.button, interaction: nextcord.Interaction):
self.__numberPage-=1
await interaction.response.edit_message(embed=embed=createEmded('ShopBuildings', self.__shop[self.__numberPage]))
@nextcord.ui.button(label='Next Page', style=nextcord.ButtonStyle.primary)
async def NextPage(self, button: nextcord.ui.button, interaction: nextcord.Interaction):
self.__numberPage+=1
await interaction.response.edit_message(embed=createEmded('ShopBuildings', self.__shop[self.__numberPage]))
目前没有回答
相关问题 更多 >
编程相关推荐