1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] DiscordBot not answering

Discussão em 'Python' iniciado por Stack, Setembro 12, 2024.

  1. Stack

    Stack Membro Participativo

    Hello devs please help me about that. I can't understand why my Discord Bot is not responding or messaging to me. I had written the the correct code and also set my token correct and my code was:

    import discord
    import os


    TOKEN = os.environ['SECRET_KEY']

    # Initialize the bot client
    intents = discord.Intents.default()
    intents.message_content = True
    client = discord.Client(intents=intents)

    @client.event
    async def on_ready():
    print(f'Logged on as {client.user}!')

    @client.event
    async def on_message(message):
    # Ignore messages from the bot itself
    if message.author == client.user:
    return

    # Respond to a specific command (e.g., "!hello")
    if message.content.lower() == "!hello":
    await message.channel.send("Hello, world!")

    # Add more custom commands or logic here

    # Run the bot
    client.run(TOKEN)


    and on the out put it also showed logged on but at last I can't get the solution of my promblem.

    I thought that it if I reset my token then it will be ok but no, I think this is the fault of setting my discord bot because all yt tutorial I got is old as 1 to 2 year and dicord developer portal had updated. I also checked the permission of my bot too. But can't get the solution. Although I was in the the replit and also set the secret.

    Continue reading...

Compartilhe esta Página