-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbot.py
More file actions
41 lines (35 loc) · 1.56 KB
/
bot.py
File metadata and controls
41 lines (35 loc) · 1.56 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
# Discord Welcomer Bot
import discord, os, traceback, json
from colorama import Fore, init
from aiohttp import ClientSession
from discord.ext import commands
# Read config file and grab username/password
token = json.load(open('config.json', 'r'))['settings']['token']
# Declare intents
intents = discord.Intents.all()
class Client(commands.Bot):
def __init__(self):
super().__init__(command_prefix="welcomer!", intents=intents)
self.remove_command('help')
self.session: ClientSession
async def on_ready(self):
print(f"[{Fore.GREEN}!{Fore.RESET}] Bot has started successfully!") # Set up production/development bot
self.session = ClientSession(loop=self.loop)
await self.load_modules()
await self.change_presence(status=discord.Status.online, activity=discord.Game('github.com/hattvr'))
async def load_modules(self):
for path, subdirs, files in os.walk("modules"):
for name in files:
if name.endswith(".py"):
name = os.path.join(name)[:-3]
path = (os.path.join(path).replace("/", ".")).replace("\\", ".")
filepath = path + "." + name
try:
await self.load_extension(filepath)
print(f"{Fore.LIGHTGREEN_EX}Loaded:{Fore.RESET} " + filepath)
except:
print(f"{Fore.RED}Error:{Fore.RESET} {filepath}\n" + traceback.format_exc())
else:
continue
init()
Client().run(token)