Mr True
Mr True

Reputation: 3

Why doesn't it work with Python and discord.py

I'm trying to do a simple thing like a command with discord.py, but it doesn't give anything like an error in the terminal or in Discord.

Here is the code:

import discord
from discord.ext import commands

class BotLibertarin(discord.Client):
    client = commands.Bot(command_prefix=".")

    @client.command()
    async def teste(ctx,*,arg):
        await ctx.channel.send(arg)

    @client.event
    async def on_message(self, message):
        print(f"message from {message.author} what he said {message.content}")


client = BotLibertarin()
client.run("")

Upvotes: 0

Views: 775

Answers (1)

Harmon758
Harmon758

Reputation: 5157

I'm not sure how exactly your class is structured because of the improper indentation or why you're assigning client twice, but you need to subclass commands.Bot to use the commands extension, not Client.

Also, you need to use Bot.process_commands in your on_message handler.

See the Why does on_message make my commands stop working? section of the FAQ in discord.py's documentation.

Upvotes: 2

Related Questions