I am trying to create an anti-raid bot that will have 3 buttons, one of those is a lockdown button I created it but it's not sending the final response message
It returns an error - AttributeError: 'Button' object has no attribute 'response'
and shows This interaction failed
Here is my code -
class Lockdown(discord.ui.View):
@discord.ui.button(label="Lockdown", style=discord.ButtonStyle.red)
async def lockdown(self, button: discord.ui.Button, interaction: discord.Interaction):
for channel in button.guild.channels:
if isinstance(channel, discord.TextChannel):
await channel.set_permissions(button.guild.default_role, send_messages=False)
await interaction.response.send_message("All text channels are locked", ephemeral=True)
@bot.command()
async def lockdown(ctx):
view = Lockdown()
await ctx.send("Click lockdown to lock all text channels", view=view)
Simply switch the button
and interaction
arguments around.
class Lockdown(discord.ui.View):
@discord.ui.button(label="Lockdown", style=discord.ButtonStyle.red)
async def lockdown(self, interaction: discord.Interaction, button: discord.ui.Button):
for channel in button.guild.channels:
if isinstance(channel, discord.TextChannel):
await channel.set_permissions(button.guild.default_role, send_messages=False)
await interaction.response.send_message("All text channels are locked", ephemeral=True)