@bot.event
async def on_select_option(interaction):
if interaction.component.custom_id == "menu":
guild = interaction.guild
category = discord.utils.get(interaction.guild.categories, id=id_category)
rol_staff = discord.utils.get(interaction.guild.roles, id=id_staff_role)
if interaction.values[0] == 'question':
channel = await guild.create_text_channel(
name=f'❔┃{interaction.author.name}-ticket', category=category
)
await channel.set_permissions(interaction.guild.get_role(interaction.guild.id),
send_messages=False, read_messages=False)
await channel.set_permissions(interaction.author,
send_messages=True, read_messages=True, add_reactions=True,
embed_links=True, attach_files=True, read_message_history=True,
external_emojis=True)
await channel.set_permissions(rol_staff,
send_messages=True, read_messages=True, add_reactions=True,
embed_links=True, attach_files=True, read_message_history=True,
external_emojis=True, manage_messages=True)
await interaction.send(
f'> The {channel.mention} channel was created to solve your questions.',
delete_after=3
)
embed_question = discord.Embed(
title=f'Question - ¡Hi {interaction.author.name}!',
description='In this ticket we have an answer to your question.\n\n'
'If you cant get someone to help you, press the button `🔔 Call staff`..',
color=embed_color
)
embed_question.set_thumbnail(url=interaction.author.avatar_url)
await channel.send(
interaction.author.mention, embed=embed_question,
components=[[
Button(custom_id='close_ticket', label="Close ticket",
style=ButtonStyle.red, emoji='🔐'),
Button(custom_id='call_staff', label="Call staff",
style=ButtonStyle.blue, emoji='🔔')
]]
)
elif interaction.values[0] == 'help':
channel = await guild.create_text_channel(
name=f'🔧┃{interaction.author.name}-ticket', category=category
)
await channel.set_permissions(interaction.guild.get_role(interaction.guild.id),
send_messages=False, read_messages=False)
await channel.set_permissions(interaction.author,
send_messages=True, read_messages=True, add_reactions=True,
embed_links=True, attach_files=True, read_message_history=True,
external_emojis=True)
await channel.set_permissions(rol_staff,
send_messages=True, read_messages=True, add_reactions=True,
embed_links=True, attach_files=True, read_message_history=True,
external_emojis=True, manage_messages=True)
await interaction.send(
f'> The {channel.mention} channel was created to help you.',
delete_after=3
)
embed_question = discord.Embed(
title=f'Help - ¡Hi {interaction.author.name}!',
description='In this ticket we can help you with whatever you need.\n\n'
'If you cant get someone to help you, press the button `🔔 Call staff`.',
color=embed_color
)
embed_question.set_thumbnail(url=interaction.author.avatar_url)
await channel.send(
interaction.author.mention, embed=embed_question,
components=[[
Button(custom_id='close_ticket', label="Close ticket",
style=ButtonStyle.red, emoji='🔐'),
Button(custom_id='call_staff', label="Call staff",
style=ButtonStyle.blue, emoji='🔔')
]]
)
elif interaction.values[0] == 'report':
channel = await guild.create_text_channel(
name=f'🚫┃{interaction.author.name}-ticket', category=category
)
await channel.set_permissions(interaction.guild.get_role(interaction.guild.id),
send_messages=False, read_messages=False)
await channel.set_permissions(interaction.author,
send_messages=True, read_messages=True, add_reactions=True,
embed_links=True, attach_files=True, read_message_history=True,
external_emojis=True)
await channel.set_permissions(rol_staff,
send_messages=True, read_messages=True, add_reactions=True,
embed_links=True, attach_files=True, read_message_history=True,
external_emojis=True, manage_messages=True)
await interaction.send(
f'> The {channel.mention} channel was created to report to the user.',
delete_after=3
)
embed_question = discord.Embed(
title=f'Report - ¡Hi {interaction.author.name}!',
description='In this ticket we can help you with your report.\n\n'
'If you cant get someone to help you, press the button `🔔 Call staff`.',
color=embed_color
)
embed_question.set_thumbnail(url=interaction.author.avatar_url)
await channel.send(
interaction.author.mention, embed=embed_question,
components=[[
Button(custom_id='close_ticket', label="Close ticket",
style=ButtonStyle.red, emoji='🔐'),
Button(custom_id='call_staff', label="Call staff",
style=ButtonStyle.blue, emoji='🔔')
]]
)