-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
68 lines (52 loc) · 1.84 KB
/
bot.py
File metadata and controls
68 lines (52 loc) · 1.84 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# bot.py
# Imports
# ==========================================================================================
import os
import discord
import asyncio
import datetime
import discord.ui
from discord.ext import commands
from discord.ext.commands import CommandNotFound, BadArgument, MissingRequiredArgument
from dotenv import load_dotenv
from datetime import datetime
# .env
# ==========================================================================================
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
h_embed = discord.Embed(color=discord.Color.blurple()) # Help
e_embed = discord.Embed(color=discord.Color.red()) # Error
# BOT INIT
# ==========================================================================================
intents = discord.Intents.all()
bot = commands.Bot(command_prefix="!", intents=intents, case_insensitive=True, help_command=None)
# bot = commands.Bot(command_prefix="!", intents=intents, case_insensitive=True)
bot.remove_command("help")
# Code
# ==========================================================================================
@bot.command(description="test")
async def pcog(ctx, cog_name):
"""
Testing cod.
"""
cog = bot.get_cog(cog_name)
commands = cog.get_commands()
print([c.name for c in commands])
async def load_extensions():
"""
Load needed extensions (i.e. Cogs).
"""
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
# print ("", filename)
await bot.load_extension(f"cogs.{filename[:-3]}")
# RUN
# ==========================================================================================
async def main():
"""
Main function.
"""
async with bot:
await load_extensions()
await bot.start(TOKEN)
asyncio.run(main())