I have a view class:
class genagain(discord.ui.View):
@discord.ui.button(label="U1", style=discord.ButtonStyle.primary, custom_id="u1", row=0)
async def button_callback(self, button, interaction):
await interaction.response.defer()
await interaction.response("Generating again...")
@discord.ui.button(label="U2", style=discord.ButtonStyle.primary, custom_id="u2", row=0)
async def button_callback(self, button, interaction):
await interaction.response.defer()
await interaction.response("Generating again...")
@discord.ui.button(label="U3", style=discord.ButtonStyle.primary, custom_id="u3", row=0)
async def button_callback(self, button, interaction):
await interaction.response.defer()
await interaction.response("Generating again...")
@discord.ui.button(label="U4", style=discord.ButtonStyle.primary, custom_id="u4", row=0)
async def button_callback(self, button, interaction):
await interaction.response.defer()
await interaction.response("Generating again...")
@discord.ui.button(label="", style=discord.ButtonStyle.primary, emoji="🔄", custom_id="genagain", row=1)
async def button_callback(self, button, interaction):
await interaction.response.defer()
await interaction.response("Generating again...")
@discord.ui.button(label="V1", style=discord.ButtonStyle.primary, custom_id="v1", row=2)
async def button_callback(self, button, interaction):
await interaction.response.defer()
await interaction.response("Generating again...")
@discord.ui.button(label="V2", style=discord.ButtonStyle.primary, custom_id="v2", row=2)
async def button_callback(self, button, interaction):
await interaction.response.defer()
await interaction.response("Generating again...")
@discord.ui.button(label="V3", style=discord.ButtonStyle.primary, custom_id="v3", row=2)
async def button_callback(self, button, interaction):
await interaction.response.defer()
await interaction.response("Generating again...")
@discord.ui.button(label="V4", style=discord.ButtonStyle.primary, custom_id="v4", row=2)
async def button_callback(self, button, interaction):
await interaction.response.defer()
await interaction.response("Generating again...")
What the code should do is to create 9 buttons of 3 rows and respond "Generating again..." if the button is pressed.
Why there is only the last button displaying?
Each button needs it's own unique callback function. Did you try renaming the various functions?