[英]Lock Channels For Everyone discord.py
so i was trying to make a raidmode command and i want it to revoke send_messages perms to all channels.... but im getting an error.所以我试图做一个raidmode命令,我希望它撤销所有频道的send_messages perms....但我得到一个错误。 any help is appriciated: :D
任何帮助都会得到帮助::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
ERROR错误
channels = guild.get_all_channels()
AttributeError: 'Guild' object has no attribute 'get_all_channels'
You're going to need Guild.channels
你需要
Guild.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)
Also, keep in mind that because allow permissions override deny permissions, this may not work for all channels.另外,请记住,由于允许权限覆盖拒绝权限,这可能不适用于所有渠道。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.