1

how do I have multiple args in one command in discord.py?

for example user: /say string bot: string

or user: /repeat integer bot: (repeats something a number of times)

or user: /kill @mention bot: user killed @mention

and is there a way where you can put them all into one command?

1
  • I don't really understand what you're trying to do here. Do you have some code demonstrating your current usage of slash commands and what you want to change about it? I don't see any of your commands having multiple arguments in your three examples. Commented Nov 27, 2021 at 21:16

1 Answer 1

1

I believe this code should solve your problem:

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='/')

@bot.command()
async def say(ctx, string: str):
    await ctx.send(string)

@bot.command()
async def repeat(ctx, integer: int):
    for i in range(integer):
        await ctx.send("Repeating something")

@bot.command()
async def kill(ctx, mention: discord.Member):
    await ctx.send("user killed {}".format(mention))
Sign up to request clarification or add additional context in comments.

2 Comments

thanks! you just forgot to add await
another problem is that for the string one it can only send 1 word

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.