![](/img/trans.png)
[英]Hide all channels except one for everyone except some roles discord.py
[英]Lock Channels For Everyone discord.py
所以我試圖做一個raidmode命令,我希望它撤銷所有頻道的send_messages perms....但我得到一個錯誤。 任何幫助都會得到幫助::D
@commands.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def raidmode(self, ctx, section):
if section == 'on':
guild = ctx.guild
channels = guild.get_all_channels()
role = discord.utils.get(guild.roles, name="@everyone")
await channels.set_permissions(role, send_messages=False)
mbed = discord.Embed(description="Raid Mode Is Enabled!", color=0xe74c3c)
await ctx.send(embed=mbed)
return
if section == 'off':
guild = ctx.guild
channels = guild.get_all_channels()
role = discord.utils.get(guild.roles, name="@everyone")
await channels.set_permissions(role, send_messages=True)
m1bed = discord.Embed(description="Raid Mode Is Disabled!", color=0xe74c3c)
await ctx.send(embed=m1bed)
return
錯誤
channels = guild.get_all_channels()
AttributeError: 'Guild' object has no attribute 'get_all_channels'
channels = ctx.guild.channels
everyone_role = guild.roles[0] # strictly get the @everyone role (lowest in hierarchy), in case an owner has a role named @everyone
for channel in channels:
if isinstance(channel, discord.TextChannel): # don't change permissions for voice chat or categories
await channel.set_permissions(role, send_messages=False)
另外,請記住,由於允許權限覆蓋拒絕權限,這可能不適用於所有渠道。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.