forked from Sirspam/Discord.py-Bot-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
54 lines (39 loc) · 1.17 KB
/
bot.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
50
51
52
53
54
import logging
from os import getcwd, getenv
from discord import Intents, AllowedMentions
from dotenv import load_dotenv
from discord.ext import commands
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
load_dotenv(getcwd()+"/.env")
DEFAULT_PREFIX = getenv("DEFAULT_PREFIX")
bot = commands.Bot(
command_prefix=DEFAULT_PREFIX,
intents=Intents.default(),
case_insensitive=True,
allowed_mentions=AllowedMentions(
everyone=False,
roles=False,
replied_user=False
)
)
initial_cogs = [
"jishaku",
"cogs.error_handler",
"cogs.general"
]
for cog in initial_cogs:
try:
bot.load_extension(cog)
logging.info(f"Successfully loaded {cog}")
except Exception as e:
logging.error(f"Failed to load cog {cog}: {e}")
@bot.event
async def on_ready():
logging.info(f"Bot has successfully launched as {bot.user}")
@bot.before_invoke
async def before_invoke(ctx):
logging.info(f"Invoked {ctx.command} in {ctx.guild.name} by {ctx.author.name}\nArgs: {ctx.args}")
@bot.after_invoke
async def after_invoke(ctx):
logging.info(f"Concluded {ctx.command}")
bot.run(getenv("TOKEN"))