【发布时间】:2021-11-10 12:04:53
【问题描述】:
我发出了一个锁定命令,但是当fl.lock #general test 用于#general 频道时,它不会锁定通用频道,但当fl.lock #general test 用于#staff-chat 频道时,它会锁定#general 频道
因此,当 lock 命令中提到该频道并且在同一频道中使用该频道时,我的机器人不会锁定频道
代码
@commands.command(case_insensitive = True)
@commands.has_any_role(885434191783788564, 856071314740740096, 856061783722426378, 856465667296985108)
async def lock(self, ctx, channel: discord.TextChannel, *, reason=None):
channel = channel or ctx.channel
overwrite = channel.overwrites_for(ctx.guild.default_role)
if overwrite.send_messages == True:
overwrite.send_messages = False
await channel.set_permissions(ctx.guild.default_role, overwrite=overwrite)
em_reason = discord.Embed(title="**Channel locked**", description=f":lock: {reason}",color=discord.Color.red())
embed = discord.Embed(description = f"<a:fl_check:874522235879186483> Locked channel <#{channel.id}>",color=discord.Color.green())
await ctx.send(embed=em_reason)
await ctx.send(embed=embed)
elif overwrite.send_messages == False:
em = discord.Embed(description="<a:fl_no:874522273984442420> That channel is already locked.", color=discord.Color.red())
await ctx.send(embed=em)```
【问题讨论】:
标签: python discord discord.py