Guest User

Ticket Close Stopped Working

a guest
Sep 11th, 2022
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.20 KB | None | 0 0
  1. @discord.ui.button(label='Close A Ticket', style=discord.ButtonStyle.success, emoji='🔹')
  2.     async def close_button_callback(self, button, interaction):
  3.         channel = interaction.channel
  4.         user = interaction.user
  5.         ticketOwner = channel.topic[2:20]
  6.         user2 = await client.fetch_user(ticketOwner)
  7.         print(ticketOwner)
  8.  
  9.         query = collection.find_one({'ChannelID': interaction.channel.id})
  10.         if query == None:
  11.             await interaction.channel.send('You must use this command inside of an active ticket.')
  12.             print(query)
  13.         else:
  14.             ticketchannel = interaction.channel
  15.             results = collection.find({"_id":interaction.guild.id})
  16.             for result in results:
  17.                 channel = (result['logChannel'])
  18.  
  19.  
  20.  
  21.             user = interaction.user
  22.             guild = interaction.guild
  23.  
  24.             results2 = collection.find({"TicketOwner": ''})
  25.             for result in results2:
  26.                 ticketChannel = (result['TicketOwner'])
  27.  
  28.             check = collection.find_one({'_id': interaction.guild.id})
  29.             if check == None:
  30.                 em = discord.Embed(title=f"{interaction.user.name} Closed A Ticket", description="*[--Transcript--]*")
  31.  
  32.                 messages = await ticketchannel.history(limit=500).flatten()
  33.                 for i in messages:
  34.                     print(i.content)
  35.                     print(i.author)
  36.  
  37.                     em.add_field(name=i.author, value=i.content)
  38.                     em.set_author(name=i.author)
  39.  
  40.                 messages = await ticketchannel.history(limit=500).flatten()
  41.                 for i in messages:
  42.                     print(i.content)
  43.                     print(i.author)
  44.  
  45.                     em.add_field(name=i.author, value=i.content)
  46.                     em.set_author(name=i.author)
  47.  
  48.                 await user2.send(f'Ticket Closed by: {interaction.user.mention}')
  49.                 await user2.send(embeds=[em])
  50.                 await ticketchannel.delete()
  51.                 collection.delete_one({'TicketOwner': interaction.user.id, 'ChannelID': interaction.channel.id})
  52.  
  53.             else:
  54.                 logchannel = client.get_channel(int(channel))
  55.                 em = discord.Embed(title=f"{interaction.author.name} Closed A Ticket", description="*[--Transcript--]*")
  56.  
  57.                 channel = interaction.channel
  58.                 messages = await ticketchannel.history(limit=500).flatten()
  59.                 for i in messages:
  60.                     print(i.content)
  61.                     print(i.author)
  62.                     em.add_field(name = i.author, value = i.content)
  63.                     em.set_author(name = i.author)
  64.  
  65.                 await user2.send(f'Ticket Closed by: {interaction.user.mention}')
  66.                 await user2.send(embeds=[em])
  67.                 await logchannel.send(embeds=[em])
  68.                 await ticketchannel.delete()
  69.                 collection.delete_one({'TicketOwner': interaction.user.id, 'ChannelID': interaction.channel.id})
  70.  
  71.  
  72.  
  73.  
  74.  
  75. ##ERROR
  76.  
  77.  
  78. Ignoring exception in view <Tickets timeout=180.0 children=3> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='Close A Ticket' emoji=<PartialEmoji animated=False name=':small_blue_diamond:' id=None> row=None>:
  79. Traceback (most recent call last):
  80.   File "C:\Users\dmpor\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ui\view.py", line 375, in _scheduled_task
  81.     await item.callback(interaction)
  82.   File "c:\Users\dmpor\OneDrive\Desktop\Splintar\splintar.py", line 109, in close_button_callback
  83.     await user2.send(embeds=[em])
  84.   File "C:\Users\dmpor\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\abc.py", line 1521, in send
  85.     data = await state.http.send_message(
  86.   File "C:\Users\dmpor\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 360, in request
  87.     raise HTTPException(response, data)
  88. discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
  89. In embeds.0.fields.0.value: This field is required
  90. In embeds.0.fields.1.value: This field is required
  91. In embeds.0.fields.3.value: This field is required
  92. In embeds.0.fields.4.value: This field is required
Advertisement
Add Comment
Please, Sign In to add comment