Files
discord-jeeves/jeeves.py

59 lines
1.5 KiB
Python
Raw Normal View History

2021-06-06 22:08:18 +02:00
#!/usr/bin/env python3
import discord
from discord.ext import commands
2021-06-06 22:08:18 +02:00
import logging
from jeevesbot import env
import os
2021-06-06 22:08:18 +02:00
# setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('jeeves')
logger.setLevel(logging.INFO)
handler = logging.FileHandler(filename='jeeves.log', encoding='utf-8', mode='a')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)
# setup discord.py bot
intents = discord.Intents().all()
bot = commands.Bot(command_prefix='!', intents=intents)
2021-06-06 22:08:18 +02:00
e = discord.Embed()
2021-07-09 11:11:09 +02:00
@bot.command()
@commands.has_permissions(administrator=True)
async def load(ctx, extension):
bot.load_extension(f'cogs.{extension}')
print(extension, 'module loaded')
@bot.command()
@commands.has_permissions(administrator=True)
async def unload(ctx, extension):
bot.unload_extension(f'cogs.{extension}')
print(extension, 'module unloaded')
@bot.command()
@commands.has_permissions(administrator=True)
async def reload(ctx, extension):
bot.unload_extension(f'cogs.{extension}')
bot.load_extension(f'cogs.{extension}')
print(extension, 'module reloaded')
@bot.event
2021-06-06 22:08:18 +02:00
async def on_ready():
print('### Active with id %s as %s ###' % (bot.user.id,bot.user.name) )
2021-06-15 00:46:44 +02:00
activity = discord.Activity(name='!help', type=discord.ActivityType.listening)
await bot.change_presence(activity=activity)
2021-06-06 22:08:18 +02:00
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
bot.load_extension(f'cogs.{filename[:-3]}')
2021-06-06 22:08:18 +02:00
if __name__ == '__main__':
bot.run(env.TOKEN)