-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
56 lines (37 loc) · 1.43 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
import discord
from discord.ext import commands
import os
import py_dotenv
import json
from discord.ext import commands
py_dotenv.read_dotenv(os.path.join(os.path.dirname(__file__), ".env"))
intents = discord.Intents.all()
def get_prefix(bot, message):
with open("./resources/prefixes.json") as f:
prefixes = json.load(f)
default_prefix = prefixes.get("default")
if not message.guild:
return commands.when_mentioned_or(default_prefix)(bot, message)
if str(message.guild.id) not in prefixes:
return commands.when_mentioned_or(default_prefix)(bot, message)
prefix = prefixes[str(message.guild.id)]
return commands.when_mentioned_or(prefix, default_prefix)(bot, message)
bot = commands.Bot(
command_prefix=get_prefix,
intents=intents,
case_insensitive=True,
strip_after_prefix=True,
help_command=None,
)
for filname in os.listdir(f"./commands"):
if filname.endswith(".py"):
bot.load_extension(f"commands.{filname[:-3]}")
for filname in os.listdir("./events"):
if filname.endswith(".py"):
bot.load_extension(f"events.{filname[:-3]}")
for filname in os.listdir("./economy"):
if filname.endswith(".py"):
bot.load_extension(f"economy.{filname[:-3]}")
bot.run(os.getenv("TOKEN"))
# py -Bc "import pathlib; [p.unlink() for p in pathlib.Path('.').rglob('*.py[co]')]"
# py -Bc "import pathlib; [p.rmdir() for p in pathlib.Path('.').rglob('__pycache__')]"