-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (31 loc) · 1.19 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import asyncio
import os
import discord
import dotenv
from discord.ext import commands
from extras.CustomLogger import CustomLogger
logger = CustomLogger(CustomLogger.DEBUG)
dotenv.load_dotenv()
BOT_TOKEN = os.getenv('BOT_TOKEN')
bot = commands.Bot(command_prefix="$", intents=discord.Intents.all())
testGuild = discord.Object(id=os.getenv('TEST_GUILD')) # for testing
async def load_extensions():
for filename in os.listdir("./cogs"):
if filename.endswith(".py") and filename.endswith("Commands.py"):
await bot.load_extension(f"cogs.{filename[:-3]}")
logger.log(f"Loaded cogs.{filename}", logger.INFO)
@bot.event
async def on_app_command_completion(interaction: discord.Interaction, command: discord.app_commands.Command) -> None:
server = interaction.guild.name
user = interaction.user
logger.log(f"[[{user}]] RAN [[{command.name}]] IN [[{server}]]", logger.INFO)
@bot.event
async def on_ready() -> None:
await bot.wait_until_ready()
await bot.tree.sync()
logger.log(f"Logged in as: {bot.user}", logger.INFO)
async def main():
await load_extensions()
await bot.start(token=BOT_TOKEN)
if __name__ == "__main__":
asyncio.run(main())