我正在尝试发出一条命令来更改所有文本通道的权限 但这不起作用
@bot.command()
async def close_all(ctx):
overwrite = discord.PermissionOverwrite()
overwrite.send_messages = False
overwrite.read_messages = False
ctx.get_channel = ctx.message.server
await ctx.channel.set_permissions(ctx.guild.default_role, overwrite=overwrite)
我也试图放guild
,但它说AttributeError: 'Guild' object has no attribute 'channel'
@bot.command()
async def close_all(ctx):
await ctx.guild.channel.set_permissions(ctx.guild.default_role, send_messages=False)
答案 0 :(得分:2)
Guild
没有属性channel
,但确实有channels
,它是行会中可以循环通过的所有频道的列表:
for chan in guild.channels:
await chan.set_permissions(cts.guild.default_role, send_messages=False)