-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
56 lines (43 loc) · 1.71 KB
/
bot.py
File metadata and controls
56 lines (43 loc) · 1.71 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
import asyncio
import os
from discord import Intents
from discord.ext import commands
from PyDiscordBot.utils import DataUtils
intents = Intents.default()
# Restricted intent
intents.members = True
intents.presences = True
# Disabling default
intents.typing = False
intents.bans = False
intents.webhooks = False
intents.invites = False
class Bot(commands.Bot):
async def get_prefix(bot, message):
return DataUtils.prefix(message.guild)
async def load_events(self):
await self.wait_until_ready()
events = await DataUtils.load_future_events(self)
print(f"Done loading {events} future actions")
def __init__(self):
super().__init__(command_prefix=self.get_prefix, intents=intents)
print("Loading future actions")
asyncio.ensure_future(self.load_events(), loop=self.loop)
self.load_plugins()
print(f"Loaded {len(self.extensions)} extensions")
def load_plugins(self):
for r, d, f in os.walk("PyDiscordBot/"):
for file in f:
if str(file).endswith(".py"):
file = r + "." + file
for c in (("/", "."), ("\\", ".")): file = file.replace(*c)
try:
self.load_extension(f"{file.strip('.py')}")
except Exception as e:
if not isinstance(e, commands.NoEntryPointError):
print("{0}: {1}".format(type(e).__name__, e))
async def on_ready(self):
print(f"Connected as: {self.user} - {self.user.id}\n")
async def on_message(self, message):
pass # I need this for the on_message in events for some reason
bot = Bot().run(DataUtils.config_data("token"))