[Python] Discord.py, commands.error: "roll" not found

Discussão em 'Python' iniciado por Stack, Abril 20, 2025.

  1. Stack

    Stack Membro Participativo

    I just started studying Python this week and I don't understand what I'm doing wrong. My discord bot is online, but every time I try to type a command in Discord it pings back to VS Code as

    "discord.ext.commands.errors.CommandNotFound: Command "roll" is not found Ignoring exception in command None:

    It's not just roll command, it doesn't seem to be registering any commands. What should I do?

    import discord
    from discord.ext import commands
    import random

    TOKEN = 'token hidden'

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

    @bot.event
    async def on_ready():
    print(f'We have logged in as {bot.user}')

    @bot.command()
    async def ping(ctx):
    await ctx.send('Pong!')

    @client.command()
    async def roll(ctx, dice: str):
    """Rolls a dice in NdN format."""
    try:
    rolls, limit = map(int, dice.split('d'))
    except Exception:
    await ctx.send('Format has to be in NdN!')
    return

    result = ', '.join(str(random.randint(1, limit)) for r in range(rolls))
    await ctx.send(result)

    bot.run(TOKEN)

    Continue reading...

Compartilhe esta Página