-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
49 lines (37 loc) · 1.15 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
48
49
## Import statements
from discord.ext import commands
from dataclasses import dataclass, field
import discord
import os # default module
from dotenv import load_dotenv
load_dotenv()
cogs_list = [
'functionality',
'fun',
'timetracking',
'moderation'
]
#Starting the discord bot
bot = discord.Bot(command_prefix="$", help_command=commands.DefaultHelpCommand())
for cog in cogs_list:
print(f"Loading Cog {cog}")
bot.load_extension(f'cogs.{cog}')
@bot.event
async def on_ready():
await synced()
print("Hello! Chromes Py-Bot is ready!")
channel = bot.get_channel(int(os.getenv('BOT_LOG_ID')))
await channel.send("Hello! Chromes Py-Bot is ready!")
async def synced():
if bot.auto_sync_commands:
await bot.sync_commands()
print(f"{bot.user.name} connected.")
for cmd in bot.commands:
print(f"Syncing: {cmd}")
await bot.process_application_commands(cmd)
@bot.slash_command(description="Shutdown the bot. [Only BOT owner can use this command]")
@commands.is_owner()
async def shutdown(ctx):
await ctx.respond("Shutting down the bot...")
await bot.close()
bot.run(os.getenv('BOT_TOKEN'))