Cobular / distest

A library used to do integration testing on discord bots
MIT License
29 stars 8 forks source link

my bot doesn't answer distest bot, but me #40

Closed grauschnabel closed 3 years ago

grauschnabel commented 3 years ago

Hi there,

When I try to use distest, i get the message, my bot is present, but not online. In my discord app I see it online and it is answering my commands. But my bot does not answer the distest bot. Did I miss something?

Thanks, Martin

grauschnabel commented 3 years ago

I figured it out. My solution was to inherit the discord.py bot:

class MyBot(commands.Bot):
    async def process_commands(self, message):

        """
        By default the bot does not forward messages to commands if
        these come from a bot.

        Here we override this behaviour and give the app a config switch
        to make it possible to test it by a bot.
        """
        if not Config().answer_bots:
            return super.process_commands(message)

        ctx = await self.get_context(message)
        await self.invoke(ctx)
Cobular commented 3 years ago

Cool! I'll be making a patcher function that does this for you soon, it's in the works right now