43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
from typing import Optional, List
|
|
from os import getenv, listdir
|
|
import discord
|
|
|
|
from discord import app_commands
|
|
from discord.app_commands import Choice
|
|
from discord.ext import commands
|
|
from dotenv import load_dotenv
|
|
|
|
|
|
load_dotenv()
|
|
|
|
|
|
class MyClient(commands.Bot):
|
|
def __init__(self):
|
|
intents = discord.Intents.none()
|
|
intents.guilds = True
|
|
intents.messages = True
|
|
super().__init__(intents=intents, command_prefix=".")
|
|
|
|
self.MY_GUILD = discord.Object(id=getenv("GUILD_ID"))
|
|
|
|
self.initial_extensions = ["cogs." + f[:-3] for f in listdir("./cogs") if
|
|
f.endswith(".py") and f.__str__() != "__init__.py"]
|
|
|
|
async def setup_hook(self):
|
|
# cogs
|
|
for extension in self.initial_extensions:
|
|
await self.load_extension(extension)
|
|
|
|
self.tree.copy_global_to(guild=self.MY_GUILD)
|
|
await self.tree.sync(guild=self.MY_GUILD)
|
|
|
|
async def on_ready(self):
|
|
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
|
print(f"Discord version : {discord.__version__}")
|
|
print('------')
|
|
|
|
|
|
if __name__ == "__main__":
|
|
client = MyClient()
|
|
client.run(getenv("TOKEN"))
|