Discord.py Run multiple Tokens with the Same Commands

Viewed 2174

im trying to do something for running multible Bots with the Same commands (Like Groovy1, Groovy2 etc)

I tried both of these and not a single worked...

client = commands.Bot(command_prefix = prefix, intents=discord.Intents().all())

@raid.command()
async def test(self, message: str):
    await ctx.send(message)

for line in open('test.txt'):
    try:
        loop.run_forever(client.run(line))
    except:
        pass
client = commands.Bot(command_prefix = prefix, intents=discord.Intents().all())

@raid.command()
async def test(self, message: str):
    await ctx.send(message)

for line in open('test.txt'):
    try:
        client.run(line)
    except:
        pass
1 Answers

This would be if you wanted to run 2 bots in 1 script. If you wanted them to react to the same command you would have to set both of their prefix's to the same characters such as ? if not have a look below.

import asyncio

loop = asyncio.get_event_loop()
loop.create_task(client.start(TOKEN1, bot=True))
loop.create_task(client2.start(TOKEN2, bot=True))
loop.run_forever()
Related