Attempting to make a simple ticket system but I believe im stuck in the old components/interactions. Just need a little boost in the right direction. Having an issue when it gets to sending the actual button for the ticket system. Cant seem to understand the issue.
Code:
import interactions
from interactions import Button, ButtonStyle, SelectMenu, SelectOption, ActionRow, Emoji
intents = discord.Intents.default()
intents.members = True
vini = commands.Bot(command_prefix = '!', intents=discord.Intents.all())
vini.remove_command('help')
@vini.command()
@commands.has_permissions(administrator=True)
async def ticket(ctx):
channel = vini.get_channel(1019066798064275507)
role1 = discord.utils.get(ctx.guild.roles, name="client")
guild = vini.get_guild(1012913549015789598)
member = ctx.author
name = 'tickets'
category = discord.utils.get(ctx.guild.categories, name=name)
overwrites = {
guild.default_role: discord.PermissionOverwrite(view_channel=False),
ctx.author: discord.PermissionOverwrite(view_channel=True),
guild.me: discord.PermissionOverwrite(view_channel=True)
}
embed1 = discord.Embed(colour=0x4ea0fd)
embed1.set_author(name="Purchase Unban", icon_url='https://i.imgur.com/b4XHLJK.png')
embed1.description ='To create a ticket click the button below'
embed2 = discord.Embed(colour=0x4ea0fd)
embed2.description ='Close Ticket'
components1 = Button(
style=ButtonStyle.PRIMARY,
label="Create a Ticket",
custom_id="button1",
emoji=Emoji(name="")
)
components2 = Button(
style=ButtonStyle.DANGER,
label="Close Ticket",
custom_id="button1"
)
msg = await channel.send(embed=embed1, components=components1)
while True:
interaction = await ctx.wait_for("button_click", check=lambda inter: inter.message.id == msg.id and inter.author.id == member.id)
channnel = await ctx.guild.create_text_channel(f'ticket-{member.name}', category=category, overwrites=overwrites)
member = interaction.author
if interaction.custom_id == "button1":
await interaction.send(content = "Creating a ticket...", ephemeral=True)
await member.add_roles(role1)
await channnel.send(f"{member.mention} created a ticket.")
msg1 = await channnel.send(embed=embed2, components=components2)
interaction1 = await ctx.wait_for("button_click")
if interaction1.custom_id == "button2":
await msg1.delete()
await interaction1.send(content = "Deleting ticket", ephemeral=True)
await asyncio.sleep(1)
await member.remove_roles(role1)
await channnel.delete()
Error:
msg = await channel.send(embed=embed1, components=components1)
TypeError: Messageable.send() got an unexpected keyword argument 'components'
The above exception was the direct cause of the following exception: