Hello, I am creating a verification button and I want the bot to respond by issuing a special role for participants after passing the time and message check, I am at the stage of the final part of the work and I need a little help highlighting errors before I start reinventing the wheel
class MyView(discord.ui.View):
@discord.ui.button(label="Verify", style=discord.ButtonStyle.primary, emoji="😎")
async def button_callback(self, button, interaction):
user = interaction.user
dt1 = user.joined_at.date()
dt2 = datetime.date.today()
tdelta = (dt2 - dt1)
mindate = datetime.timedelta(days=30)
if tdelta >= mindate:
await interaction.response.send_message(f"{user} u have {tdelta} days and u verified", ephemeral = True)
counter = 0
channel = bot.get_channel(806963162036699176)
async for message in channel.history(limit = 1_000):
if message.author == bot.user:
counter += 1
if counter >= 200:
role = interaction.get_role(856942394862600273)
await user.add_role(role)
else:
return
else:
await interaction.response.send_message(f"{user} u have {tdelta} and cant verify for events", ephemeral = True)
@bot.slash_command()
async def button(ctx):
await ctx.respond("Click the button to verify participation in events", view=MyView())




