I am making a ticket command for my bot. It works fine but, only the person oned the ticket and members with admin perms can see the channel. How can I add a support role to it? this is my current code:
rickroll alert don't go to the youtube link in the code below 🤣
@bot.event
async def on_ready():
voteRemind.start()
print('Bot is ready')
await bot.change_presence(status=discord.Status.online, activity=discord.Streaming(name="Minecraft", url="https://www.youtube.com/watch?v=dQw4w9WgXcQ"))
for channel in getTicketChannels():
embed = discord.Embed(title='Support', description="""
To create a ticket react with 🎫
<:Rules:910406026543652895> **RULES:**
Tell The Problem The Second You Open
Don't Wait For Us To Ask
""")
guild = bot.get_guild(channel[0])
channel = guild.get_channel(channel[1])
await channel.purge()
msg = await channel.send(embed=embed)
await msg.add_reaction('🎫')
@bot.event
async def on_reaction_add(reaction, user):
if user == bot.user:
return
guild = reaction.message.guild
if reaction.message.channel == guild.get_channel(getTicketChannel(guild.id)):
await reaction.remove(user)
if discord.utils.get(guild.channels, name=f"ticket-{user.display_name.lower()}"):
return
category = guild.get_channel(getTicketChannel(guild.id)).category
embed = discord.Embed(title='Welcome to your ticket!', description="Support will be with you shortly.\n\n<:Rules:910406026543652895> \nTell The Problem The Second You Open \nDon't Wait For Us To Ask", color=0x1ff44d)
overwrites = {
guild.default_role: discord.PermissionOverwrite(read_messages=False),
user: discord.PermissionOverwrite(read_messages=True)
}
ticket = await category.create_text_channel(name=f'🎫┃{user.display_name}', topic=f"{user.display_name}'s Support Channel", overwrites=overwrites)
await ticket.send(user.mention)
await ticket.send(embed=embed)
Pls let me know if you know any change to make or add @MDA
(the name of the support role) to the channel. :)
You need to add a PermissionOverwrite
for the support role as well. It'll look something like this:
support_role = discord.utils.get(guild.roles, name='MDA')
overwrites = {
guild.default_role: discord.PermissionOverwrite(read_messages=False),
user: discord.PermissionOverwrite(read_messages=True),
support_role: discord.PermissionOverwrite(read_messages=True) # or whatever permissions the role should have
}
ticket = await category.create_text_channel(name=f'🎫┃{user.display_name}', topic=f"{user.display_name}'s Support Channel", overwrites=overwrites)