0

When writing a command 2 times, even on different servers until the buttons disappear, when clicking on one of the "Remove warning" buttons, the bot responds 2 times instead of one, but at the same time only one warning is removed. Sometimes there is such an error: Command raised an exception: HTTPException: 400 Bad Request (error code: 40060): Interaction has already been acknowledged.

row - the number of warnings the user has

i - the maximum number of warns

How to fix it?

if i[0] == 0 or row[0] < i[0]:
   message = await ctx.send(embed=emb,components=[disnake.ui.Button(label='Remove the warning', style=ButtonStyle.secondary)])
   try:
       responce = await client.wait_for('button_click', check=lambda message: message.author == ctx.author,timeout=60)
   except asyncio.TimeoutError:
       await ctx.edit_original_message(components=[])
       return
   if responce.component.label == 'Remove the warning':
       await unwarnslash.unwarn_slash(ctx, member)
       await ctx.edit_original_message(components=[])
       await responce.response.defer()
elif row[0] >= i[0]:
   await ctx.send(embed=emb)
   await kickslash.kick_slash(ctx, member, 'Exceeded the number of warnings')
reToster0
  • 1
  • 1
  • Which one is being sent 2 times, first `ctx.send` or the second one? – doneforaiur Jun 15 '23 at 09:31
  • This is the warn command. The unwarn command is sent 2 times. Just unwarn is launched from a file with warn. I assume that when writing two commands, the bot waits for both (wait_for) to press the button, and since the buttons are the same, it considers any pressing of this button as pressing the second one, too – reToster0 Jun 15 '23 at 09:53
  • It's just that when writing one command, two answers do not come and everything is fine – reToster0 Jun 15 '23 at 10:06

0 Answers0