Skip to content
Advertisement

How do I do the positional parameter in discord.py

from discord.ext import commands
bbot = commands.Bot(command_prefix='!')
@bbot.command()
async def test(ctx, arg):
    await ctx.send(arg)

This is not working. I totally followed what documentation says, but the bot doesn’t repond to me when I type “!test hello”

It should work like this, but mine has nothing respond to me, idk what’s wrong at all

This is the original documentation https://discordpy.readthedocs.io/en/latest/ext/commands/commands.html#parameters

Advertisement

Answer

Your whole code should look like this. You are in the right documentation keep going.

P.S: It is a best practice to name it bot instead of bbot

import discord
from discord.ext import commands

intents = discord.Intents().all() # this is a new thing
bbot = commands.Bot(command_prefix="!", intents=intents)

@bbot.event
async def on_ready():
    print("Logged in as")
    print(bot.user.name)
    print("------")
    # here you can start your background tasks
    #randomtask.start()

@bbot.command()
async def test(ctx, arg):
    await ctx.send(arg)

bbot.run('Token Here')
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement