[QUESTION] Multiple instances.
Nucito opened this issue · 2 comments
Nucito commented
It's possible to run multiple bots? i try create tasks but don't work propely:
from twitchio.ext import commands
import json
import asyncio
STATUS = {"Count": 0, "ADMINs": ["ADM1", "ADM2"]}
class Bot(commands.Bot):
def __init__(self, token):
super().__init__(
token=token,
prefix="!",
initial_channels=["channeltest"],
)
STATUS["Count"] += 1
async def event_ready(self):
print(f"Logged in as [{self.nick}]")
@commands.command()
async def botcount(self, ctx: commands.Context):
if self.nick != "BotMain":
return
await ctx.send(f"BOTS: {STATUS['Count']}")
async def start_bots():
with open("tokens.json", "r") as fl:
CONFIG = json.load(fl)
tasks = []
for user in CONFIG["users"]:
bot = Bot(user["token"])
tasks.append(asyncio.ensure_future(bot.start()))
await asyncio.gather(*tasks)
asyncio.run(start_bots())
All the bot start without any problem but all of them have the same name if i call self.nick.
github-actions commented
Hello! Thanks for the issue. If this is a general help question, for a faster response consider joining the official Discord Server
Else if you have an issue with the library please wait for someone to help you here.