【发布时间】:2020-10-23 16:05:54
【问题描述】:
这是我的代码,它只锁定我当前所在的频道,我觉得有点愚蠢,因为我认为我应该知道这个大声笑。例如,我想说'-lock #channelname 但它只锁定我当前的频道。
@client.command()
@commands.has_permissions(manage_channels=True)
async def lock(ctx, channel : discord.TextChannel=None):
overwrite = ctx.channel.overwrites_for(ctx.guild.default_role)
overwrite.send_messages = False
await ctx.channel.set_permissions(ctx.guild.default_role, overwrite=overwrite)
await ctx.send('Channel locked.')
@lock.error
async def lock_error(ctx, error):
if isinstance(error,commands.CheckFailure):
await ctx.send('You do not have permission to use this command!')
【问题讨论】:
标签: python discord.py