Search code examples
pythondiscorddiscord.pybotschatbot

communication between two bots? (discord.py)


I'm a beginner-intermediate level programmer working with discord.py for the first time. I want to create two bots that, when one is prompted, both send messages one after another as if in a conversation.

Is that even possible in discord.py? I considered making two different bots in two different .py files, creating variables for each line of the conversation for both bots, and then having them each prompt if the message content matched the variable. However, I don't want the bots to prompt if the line is said by someone other than the other bot.

Any advice? Thanks so much!


Solution

  • You can use on_message event and check if the id of the author is the id of second bot. Example:

    @bot.event
    async def on_message(message):
        if not message.author.id == 0000: # id of another bot
            return
        # rest of the code