[Python] Discord bot function failing

Discussão em 'Python' iniciado por Stack, Maio 19, 2025.

  1. Stack

    Stack Membro Participativo

    I'm rather new to coding but I've been following this tutorial to a t so far (https://www.youtube.com/watch?v=YD_N6Ffoojw) yet the discord bot I'm coding refuses to run? I thought I had finally ironed out all the problems with the imports but it seems not? here is my code

    import discord

    from discord.ext import commands

    import dotenv

    import logging

    from dotenv import load_dotenv

    import os

    load_dotenv()
    token = os.getenv('DISCORD_TOKEN')
    handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
    intents = discord.Intents.default()
    intents.message_content = True
    intents.members = True

    bot = commands.bot(command_prefix='!', intents=intents)

    @bot.event
    async def on_ready():
    print(f"this is a test message from {bot.user.name}")

    bot.run(token, log_handler=handler, log_level=logging.DEBUG)


    it only spits out an error when I try to run it. The error is

    Traceback (most recent call last):
    File "c:\Users\myfulllegalname\Desktop\martinscatinator\main.py", line 20, in <module>
    bot = commands.bot(command_prefix='!', intents=intents)
    TypeError: 'module' object is not callable


    I can't make sense of it at all... also I think I'm running it in a venv python environment, it was the only way the imports would work.

    Continue reading...

Compartilhe esta Página