Create a variable with nessage to use it in next bot event
I have these 4 variables in my code: GUILD_ID, TEAM_ROLE, TICKET_CHANNEL, CATEGORY_ID
I want them to be created with the ticketmsg command.
Like this: .ticketmsg 854083780788355074 854083780788355074 854083780788355074 854083780788355074 of the numbers should be declared by the user.
I thought about adding a arg behind the ctx in line 3 (without variables) but then i cant use it in the next bot.event where the variable is needed right?
I hope you get my point and can help me. Of course i would appreciate code examples.
GUILD_ID = 854083780788355074 # Server ID eintragen! arg1
TEAM_ROLE = 955776396242853929 # Die Rolle, welches die Tickets sehen soll! arg2
TICKET_CHANNEL = 955798595355959296 # Der Channel, wo Tickets geöffnet werden sollen! arg3
CATEGORY_ID = 955776819397808159 # Die Kategorie, wo die Tickets erstellt werden sollen! arg4
@bot.command()
@commands.has_guild_permissions(administrator=True)
async def ticketmsg(ctx):
button1 = Button(label="Ticket öffnen!", style=discord.ButtonStyle.blurple, custom_id="ticket_button")
view = View()
view.add_item(button1)
embed = discord.Embed(description=f"Hier kommt deine Beschreibung rein!", title=f"Ticket System")
channel = bot.get_channel(TICKET_CHANNEL)
await channel.send(embed=embed, view=view)
await ctx.reply("Gesendet!")
@bot.event
async def on_interaction(interaction):
if interaction.channel.id == TICKET_CHANNEL:
if "ticket_button" in str(interaction.data):
guild = bot.get_guild(GUILD_ID)
for ticket in guild.channels:
if str(interaction.user.id) in ticket.name:
embed = discord.Embed(description=f"You can only create one ticket per time! Please close the other ticket first! {ticket.mention}")
await interaction.response.send_message(embed=embed, ephemeral=True, delete_after=1)
return
category = bot.get_channel(CATEGORY_ID)
ticket_channel = await guild.create_text_channel(f"ticket-{interaction.user.id}", category=category,
topic=f"Ticket by {interaction.user} \nClient-ID: {interaction.user.id}")
await ticket_channel.set_permissions(guild.get_role(TEAM_ROLE), send_messages=True, read_messages=True, add_reactions=False,
embed_links=True, attach_files=True, read_message_history=True,
external_emojis=True)
await ticket_channel.set_permissions(interaction.user, send_messages=True, read_messages=True, add_reactions=False,
embed_links=True, attach_files=True, read_message_history=True,
external_emojis=True)
embed = discord.Embed(description=f'Welcome {interaction.user.mention}!\n'
f'Please explain your problem and we will help you soon!\n'
f'Close the ticket with`.close` !',
color=62719)
embed.set_author(name=f'New Ticket!')
mess_2 = await ticket_channel.send(embed=embed)
embed = discord.Embed(title=" | Opened ticket!",
description=f'Your ticket was created! {ticket_channel.mention}',
color=discord.colour.Color.green())
await interaction.response.send_message(embed=embed, ephemeral=True, delete_after=1)
return