一个机器人中有一个现成的命令,它可以工作。当我尝试为第二个机器人编写它时,它显示错误:
Command raised an exception: TypeError: timeout() got some positional-only arguments passed as keyword arguments: 'until'
这是命令本身:
@bot.command(aliases=['mute', 'мут', 'мьют', 'timemute'])
@commands.has_permissions(kick_members=True)
async def timeout(ctx, member: discord.Member, time=None, *, reason=None):
author = ctx.author
if member != None:
if time != None:
t = humanfriendly.parse_timespan(time)
await member.timeout(until = discord.utils.utcnow() + datetime.timedelta(seconds=t), reason=reason)
if reason != None:
embed = discord.Embed(
title = 'Mute ✅',
description = f'**{member.mention}** успешно замучен на **{time}**\n\n**Причина: `{reason}`**',
colour = discord.Colour.from_rgb(0, 189, 0)
)
await ctx.send(embed=embed) #await ctx.send (f'**{member.mention}** был замучен на **{time}** по причине **"{reason}"**')
else:
embed = discord.Embed(
title = 'Mute ✅',
description = f'**{member.mention}** успешно замучен на **{time}**',
colour = discord.Colour.from_rgb(0, 189, 0)
)
await ctx.send(embed=embed) #await ctx.send (f'**{member.mention}** был замучен на **{time}**')
else:
embed = discord.Embed(
title = 'Mute ❌',
description = f'{author.mention} укажите время наказания',
colour = discord.Colour.from_rgb(171, 0, 0)
)
await ctx.send(embed=embed)
else:
embed = discord.Embed(
title = 'Mute ❌',
description = f'{author.mention} укажите кого нужно наказать',
colour = discord.Colour.from_rgb(171, 0, 0)
)
await ctx.send(embed=embed)
问题是什么以及如何解决?
还没有做任何超时,但我测试了你的代码并通过删除 until 值来修复它:
所以代码可以正常工作并使用户感到困惑。
完整代码: