L
L
Libertatis2022-01-26 15:15:10
Python
Libertatis, 2022-01-26 15:15:10

The play function does not accept the url argument, what should I do?

Hello, I'm writing a discord music bot and I've run into a problem. I wrote the video queue and play code separately, and now I'm trying to combine them. To do this, I entered the url argument in brackets to def play, but it complains and displays an error

TypeError: play() missing 1 required keyword-only argument: 'url'

What to do?
Now my def start looks like this: Thanks in advance, and sorry if this is a dumb question.
async def play(ctx, *, command = None, url):

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nkno, 2022-01-26
@Libertatis

Hey! I have a counter question: do you write play in the main file or in cog?
There are 2 solutions:
- First, if you have kogi

@commands.command()
    async def play(self, ctx: commands.Context, url: str, *args: str):
        '''Adds a song to the queue either by YouTube URL or YouTube Search.'''

- Second, if you have everything in the main file
@client.command()
async def play(ctx, url : str):

Good luck writing the bot!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question