1

I'm trying to create a timeout command with the new timeout function here

My code:

@commands.command()
async def timeout(self, ctx, member: discord.Member, time, reason, /):
  await member.timeout(until=datetime.timedelta(seconds=int(time)), reason=reason)

I get this error:

TypeError: timeout() got some positional-only arguments passed as keyword arguments: 'until'

I did a research on positional-only arguments, but no luck. Any fix?

Inj3ct0r
  • 75
  • 1
  • 1
  • 7
  • 2
    This video will explain this in detail: [Positional-only and keyword-only arguments in Python](https://youtu.be/R8-oAqCgHag). That channel generally produces a ton of helpful Python content, not just this one video. – asynts Aug 29 '22 at 11:12
  • 2
    Does this answer your question? [What does the slash mean in help() output?](https://stackoverflow.com/questions/24735311/what-does-the-slash-mean-in-help-output) – asynts Aug 29 '22 at 11:14
  • Found the solution, ty brat! – Inj3ct0r Aug 29 '22 at 11:20

1 Answers1

0

I found the solution, here is the working command!

@commands.command()
async def timeout(self, ctx, member: discord.Member, time, /, reason):
  await member.timeout(datetime.timedelta(seconds=int(time)), reason=reason)
Inj3ct0r
  • 75
  • 1
  • 1
  • 7