I keep getting this error for a Discord.py button and after searching the internet I still cant find out why it is happening.
Any help would be greatly appreciated.
Thanks!
AttributeError: 'submitButton' object has no attribute '_row'
class submitButton(discord.ui.Button):
def __init__(self):
@discord.ui.button(label="Submit Entry", style=discord.ButtonStyle.blurple, row=3)
async def submitEntry(self, button: discord.ui.Button, interaction:
discord.Interaction):
await self.view.submit_response(interaction)
async def submit_response(self, interaction:discord.Interaction):
# Created messageEmbed here #
await interaction.user.send(embed=messageEmbed)
await interaction.response.send_message(content="Your answers have been
submitted!", view=self, ephemeral=True,
delete_after=30)
The error occurred because you put your button when defining __init__
. You usually define __init__
as follows:
class submitButton(discord.ui.Button):
def __init__(self):
super().__init__()
Also your indentation is wrong (although that might just be how you pasted it in the question). OUTSIDE of __init__
should you add your buttons.
class submitButton(discord.ui.Button):
def __init__(self):
super().__init__()
@discord.ui.button(label="Submit Entry", style=discord.ButtonStyle.blurple, row=3)
async def submitEntry(self, button: discord.ui.Button, interaction: discord.Interaction):
await self.view.submit_response(interaction)