【发布时间】:2021-10-09 03:37:37
【问题描述】:
我有一个名为“静音”的命令:
@commands.command(description="Mutes the specified user.")
@commands.has_permissions(manage_messages=True)
async def mute(self,ctx, member: discord.Member, time = None, *, reason = None):
guild = ctx.guild #The error occurs when this line runs
mutedRole = discord.utils.get(guild.roles, name="Muted")
......
......
......
我想在 on_message 事件上使用此方法。我尝试了此方法,但收到一个错误,即“公会”对象没有“公会”属性。因此,我们可以说发生了错误因为 'ctx' 参数的参数不正确。
await self.mute(message.guild,message.author, "1d", reason= "For too many badwords")
那么在 mute 方法中我应该为参数 'ctx' 使用什么参数?
-顺便说一句,当我使用 mute 命令时:'!dc mute @person1 1d for beeeingtoxic' 它工作正常。
【问题讨论】:
标签: python discord.py