-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
68 lines (54 loc) · 1.98 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import discord
from discord.ext import commands
import os
from decouple import config
intents = discord.Intents.default()
intents.members = True
intents.guilds = True
intents.messages = True
intents.message_content = True
client = commands.Bot(
command_prefix=commands.when_mentioned_or(
"kanna ", "kana ", "k.", "K.", "Kanna ", "Kana "
),
case_insensitive=True,
intents=intents,
)
client.remove_command("help")
def load_cogs():
for file in os.listdir("./cogs"):
if file.endswith(".py") and not file.startswith("_"):
client.load_extension(f"cogs.{file[:-3]}")
load_cogs()
@client.event
async def on_ready():
print(">> Cogs Loaded.")
print(f">> Logged in as : {client.user.name} \n>> ID : {client.user.id}")
print(f">> Total Servers : {len(client.guilds)}")
await client.change_presence(
status=discord.Status.online,
activity=discord.Activity(type=discord.ActivityType.watching, name="BLUELOCK"),
)
print(">> Kanna is Online.")
@client.event
async def on_command_error(ctx: commands.Context, error):
if isinstance(error, commands.CommandNotFound):
return
elif isinstance(error, commands.MissingRequiredArgument):
await ctx.reply(f"Missing required argument, `{error.param}`")
elif isinstance(error, commands.BadArgument):
if ctx.command.usage is not None:
await ctx.reply(f"Invalid arguments, Example: `{ctx.command.usage}`")
else:
await ctx.reply("Incorrect arguments given")
@client.command()
async def reload(ctx: commands.Context, file_name: str = None):
if not file_name:
for file in os.listdir("./cogs"):
if file.endswith(".py") and not file.startswith("_"):
client.reload_extension(f"cogs.{file[:-3]}")
await ctx.send("Cogs Reloaded.")
else:
client.reload_extension(f"cogs.{file_name}")
await ctx.send(f"{file_name.capitalize()} Reloaded.")
client.run(str(config("BOT_TOKEN")))