Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @discord.ui.button(label='Close A Ticket', style=discord.ButtonStyle.success, emoji='🔹')
- async def close_button_callback(self, button, interaction):
- channel = interaction.channel
- user = interaction.user
- ticketOwner = channel.topic[2:20]
- user2 = await client.fetch_user(ticketOwner)
- print(ticketOwner)
- query = collection.find_one({'ChannelID': interaction.channel.id})
- if query == None:
- await interaction.channel.send('You must use this command inside of an active ticket.')
- print(query)
- else:
- ticketchannel = interaction.channel
- results = collection.find({"_id":interaction.guild.id})
- for result in results:
- channel = (result['logChannel'])
- user = interaction.user
- guild = interaction.guild
- results2 = collection.find({"TicketOwner": ''})
- for result in results2:
- ticketChannel = (result['TicketOwner'])
- check = collection.find_one({'_id': interaction.guild.id})
- if check == None:
- em = discord.Embed(title=f"{interaction.user.name} Closed A Ticket", description="*[--Transcript--]*")
- messages = await ticketchannel.history(limit=500).flatten()
- for i in messages:
- print(i.content)
- print(i.author)
- em.add_field(name=i.author, value=i.content)
- em.set_author(name=i.author)
- messages = await ticketchannel.history(limit=500).flatten()
- for i in messages:
- print(i.content)
- print(i.author)
- em.add_field(name=i.author, value=i.content)
- em.set_author(name=i.author)
- await user2.send(f'Ticket Closed by: {interaction.user.mention}')
- await user2.send(embeds=[em])
- await ticketchannel.delete()
- collection.delete_one({'TicketOwner': interaction.user.id, 'ChannelID': interaction.channel.id})
- else:
- logchannel = client.get_channel(int(channel))
- em = discord.Embed(title=f"{interaction.author.name} Closed A Ticket", description="*[--Transcript--]*")
- channel = interaction.channel
- messages = await ticketchannel.history(limit=500).flatten()
- for i in messages:
- print(i.content)
- print(i.author)
- em.add_field(name = i.author, value = i.content)
- em.set_author(name = i.author)
- await user2.send(f'Ticket Closed by: {interaction.user.mention}')
- await user2.send(embeds=[em])
- await logchannel.send(embeds=[em])
- await ticketchannel.delete()
- collection.delete_one({'TicketOwner': interaction.user.id, 'ChannelID': interaction.channel.id})
- ##ERROR
- 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>:
- Traceback (most recent call last):
- File "C:\Users\dmpor\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ui\view.py", line 375, in _scheduled_task
- await item.callback(interaction)
- File "c:\Users\dmpor\OneDrive\Desktop\Splintar\splintar.py", line 109, in close_button_callback
- await user2.send(embeds=[em])
- File "C:\Users\dmpor\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\abc.py", line 1521, in send
- data = await state.http.send_message(
- File "C:\Users\dmpor\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 360, in request
- raise HTTPException(response, data)
- discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
- In embeds.0.fields.0.value: This field is required
- In embeds.0.fields.1.value: This field is required
- In embeds.0.fields.3.value: This field is required
- In embeds.0.fields.4.value: This field is required
Advertisement
Add Comment
Please, Sign In to add comment