[Python] Discord.py commands aren't responding

Discussão em 'Python' iniciado por Stack, Junho 12, 2025.

  1. Stack

    Stack Membro Participativo


    1. I am trying to make a Discord bot using discord.py.


    2. I created two commands.


    3. When I sent ?hello bot didn't respond.

    Here's the code:

    import discord
    import asyncio
    import ast
    from discord.ext import commands
    intents = discord.Intents.default()
    intents.members = True
    intents.message_content = True
    bot = commands.Bot(command_prefix='?', intents=intents)

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

    @bot.event
    async def on_message(message):
    if message.author == bot.user:
    return

    if 'nigg' in message.content or 'wigg' in message.content:
    author = message.author
    guild = message.guild
    await author.add_roles(discord.utils.get(guild.roles, name='Racist'))
    await message.delete()

    @bot.command()
    async def calculate(ctx, *, expression: str):
    await ctx.send(f'{expression} = {eval(expression)}')

    @bot.command()
    async def hello(ctx):
    print('hi')
    await ctx.send('hello guys')

    bot.run('token')


    And yes – the bot was running while I typed that command.

    I tried using @bot.command() and expected bot to respond but nothing happened.

    Continue reading...

Compartilhe esta Página