This is the code:
class ticket_launcher(discord.ui.View):
def __init__(self) -> None:
super().__init__(timeout=None)
@discord.ui.Button(label='Create a ticket', style = discord.ButtonStyle.blurple, custom_id = 'ticket_button')
async def ticket(self, button: discord.ui.Button, interaction: discord.Interaction):
ticket = discord.utils.get(interaction.guild.text_channels, name = f'ticket-for-{interaction.user.name}-{interaction.user.discriminator}')
if ticket is not None: await interaction.response.send_message(f'You already have a ticket open at {ticket.mention}!', ephemeral = True)
else:
overwrites = {
interaction.guild.default_role: discord.PermissionOverwrite(view_channel = False),
interaction.user: discord.PermissionOverwrite(view_channel = True, send_messages = True, attach_files = True, embed_links = True),
interaction.guild.me: discord.PermissionOverwrite(view_channel = True, send_messages = True, read_message_history = True)
}
channel = await interaction.guild.create_text_channel(name=f'ticket-for-{interaction.user.name}-{interaction.user.discriminator}', overwrites=overwrites, reason=f'Ticket for {interaction.user}.')
await channel.send(f'{interaction.user.mention} created a ticket!')
await interaction.response.send_message(f'I have opened a ticket for you at {channel.mention}.', ephemeral=True)
tree = app_commands.CommandTree(client=client)
@tree.command(guild = discord.Object(id=TICKET_CHANNEL), name='ticket', description='Launches the ticket system.')
async def ticket(interaction: discord.Interaction):
embed = discord.Embed(title='If you have any problems click the big blue button below!', color=discord.Colour.blue())
await interaction.channel.send(embed=embed, view=ticket_launcher())
await interaction.response.send_message('Ticketing system has been launched successfully.', ephemeral=True)
it gives me this error message in the output:
Traceback (most recent call last):
File "c:\Users\schul\Desktop\MORE PYTHON\bot.py", line 214, in <module>
class ticket_launcher(discord.ui.View):
File "c:\Users\schul\Desktop\MORE PYTHON\bot.py", line 219, in ticket_launcher
async def ticket(self, button: discord.ui.Button, interaction: discord.Interaction):
TypeError: 'Button' object is not callable
So can anyone mind helping me out with this, as this kinda annoying, would be thankfull if you would've helped me out :)