我想通过一个命令来启用慢模式,命令的形式是>slowmode <seconds>,比如>slowmode 10。我当前的代码:
@has_permissions(manage_channels=True)
async def slowmode(ctx, amount):
await ctx.channel.edit.slowmode.delay(int(amount))我得到了这个错误:
Ignoring exception in command slowmode:
Traceback (most recent call last):
File "C:\Users\dante\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 83, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\dante\Desktop\Utilly\Utilly.py", line 116, in slowmode
await ctx.channel.edit.slowmode.delay(int(amount))
AttributeError: 'function' object has no attribute 'slowmode'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\dante\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\bot.py", line 892, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\dante\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 797, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\dante\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 92, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'function' object has no attribute 'slowmode'发布于 2020-05-31 23:04:17
使用discord.TextChannel.edit(slowmode_delay=amount)
@has_permissions(manage_channels=True)
async def slowmode(ctx, amount):
try:
await ctx.channel.edit(reason='Bot Slowmode Command', slowmode_delay=int(amount))
except discord.Errors.Forbidden:
await ctx.send('I do not have the permission to do this, please try again')https://stackoverflow.com/questions/62118065
复制相似问题