我有一个bot命令的代码,该命令在通道上设置自定义slowmode:
if message.author.permissions_in(message.channel).manage_channels:
if slowmode > 21600:
await ctx.send('The maximum possible slowmode is 21600, or 6 hours.')
elif slowmode < 0:
await ctx.send('The minimum possible slowmode is 0, or no slowmode.')
else:
try:
await ctx.message.channel.edit(reason='setcustomslowmode', slowmode_delay=slowmode)
await ctx.send(f'Set the slowmode of channel <#{ctx.message.channel.id}> to **{slowmode}** seconds.')
except discord.Errors.Forbidden:
await ctx.send("I'm not allowed to do that, update my permissions and try again.")
else:
await ctx.send('You need the permission `manage channel` to do this!')
它返回此回溯:
Ignoring exception in on_message
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "discordbot.py", line 1212, in on_message
await message.channel.edit(reason='Eric Bot /setcustomslowmode', slowmode_delay=int(subcommand[0]))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/channel.py", line 235, in edit
await self._edit(options, reason=reason)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/abc.py", line 285, in _edit
self._update(self.guild, data)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/channel.py", line 131, in _update
self._fill_overwrites(data)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/abc.py", line 294, in _fill_overwrites
self._overwrites.append(_Overwrites(id=overridden_id, **overridden))
TypeError: __new__() got an unexpected keyword argument 'allow_new'
编辑频道的代码工作正常(slowmode已正确更改),但随后声明slowmode已成功更改的通知从未发送
我已经尝试将reason=
参数删除为edit()
,但它只是默默地更改slowmode并引发异常,就像以前一样
This没有提到任何有关错误的信息,看起来我正确地使用了该函数
我做错了什么
您需要更新discord库版本。此错误已修复。更新到版本1.3.4,错误将被修复
python -m pip install -U discord.py
相关问题 更多 >
编程相关推荐