Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
103 views
in Technique[技术] by (71.8m points)

python - How I add a role to a channel (best without id)

import discord 
From discord.ext import commands 

@client.command() 
async def setup(ctx):

await ticket_channel.set_permissions(guild.Ticket-Helper_role, send_messages=True, read_messages=True, add_reactions=True, embed_links=True, attach_files=True, read_message_history=True, external_emojis=True, manage_channels=True)  

client.run("TOKEN") 

#What's there wrong? I want to add the role to the channel


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The Function channel.set_permissions() sets the permissions of a user in the channel.So you need to provide a target as the first argument.For example:

await ticket_channel.set_permissions(ctx.message.author, send_messages=True, read_messages=True, add_reactions=True, embed_links=True, attach_files=True, read_message_history=True, external_emojis=True, manage_channels=True)

I think what you are looking to do is restrict the channel to members with specific roles assigned to them.

for that you might want to read this documentation


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...