Multiple guilds support
This commit is contained in:
parent
78675c72c2
commit
7675b24af2
7
main.py
7
main.py
|
@ -19,7 +19,7 @@ class MyClient(commands.Bot):
|
||||||
intents.message_content = True
|
intents.message_content = True
|
||||||
super().__init__(intents=intents, command_prefix=".")
|
super().__init__(intents=intents, command_prefix=".")
|
||||||
|
|
||||||
self.MY_GUILD = discord.Object(id=getenv("GUILD_ID"))
|
self.MY_GUILDS = [discord.Object(id=int(guild_id)) for guild_id in getenv("GUILD_ID").split(',')]
|
||||||
|
|
||||||
self.initial_extensions = ["cogs." + f[:-3] for f in listdir("./cogs") if
|
self.initial_extensions = ["cogs." + f[:-3] for f in listdir("./cogs") if
|
||||||
f.endswith(".py") and f.__str__() != "__init__.py"]
|
f.endswith(".py") and f.__str__() != "__init__.py"]
|
||||||
|
@ -30,8 +30,9 @@ class MyClient(commands.Bot):
|
||||||
for extension in self.initial_extensions:
|
for extension in self.initial_extensions:
|
||||||
await self.load_extension(extension)
|
await self.load_extension(extension)
|
||||||
|
|
||||||
self.tree.copy_global_to(guild=self.MY_GUILD)
|
for guild in self.MY_GUILDS:
|
||||||
await self.tree.sync(guild=self.MY_GUILD)
|
self.tree.copy_global_to(guild=guild)
|
||||||
|
await self.tree.sync(guild=guild)
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||||
|
|
Loading…
Reference in New Issue