-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
40 lines (28 loc) · 944 Bytes
/
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
import discord
from discord.ext import commands, tasks
import os
import asyncio
intents = discord.Intents().all()
intents.message_content = True
bot = commands.Bot(command_prefix='r!', intents=intents)
@bot.command()
async def load(ctx, extension):
await bot.load_extension(f"src.{extension}")
@bot.command()
async def unload(ctx, extension):
await bot.unload_extension(f"src.{extension}")
async def load_extensions():
for filename in os.listdir("./src"):
if filename.endswith(".py"):
# cut off the .py from the file name
await bot.load_extension(f"src.{filename[:-3]}")
async def main():
secret_token = os.environ.get('BOT_TOKEN', '')
async with bot:
await load_extensions()
await bot.start(secret_token)
discord.utils.setup_logging()
@bot.event
async def on_ready():
await bot.change_presence(activity=discord.Game('Bonking Simulator'))
asyncio.run(main())