discord.py_noob
discord.py_noob

Reputation: 31

How would you extend the user input of a discord command to more than just one word?

I'm in the process of making a discord.py command that would take user input of a certain message and repeat the said message. Here is my code so far:

async def repeat(ctx, words = None):
    if words == None:
        reason = 'you didn\'t say anything dummy'
    await ctx.send(f'{words}')

However, when I go to actually test the command, the bot only sends one word of my message back. For example, if I say "do repeat a b c", it only sends "a". How would I get the bot to take all of the words I say?

Upvotes: 0

Views: 86

Answers (1)

effprime
effprime

Reputation: 578

You can use keyword-only args:

async def repeat(ctx, *, words):

This will automatically put all the args as a single string.

See: https://discordpy.readthedocs.io/en/latest/ext/commands/commands.html#keyword-only-arguments

Upvotes: 2

Related Questions