Files
discord-jeeves/jeeves.py

67 lines
1.7 KiB
Python
Raw Normal View History

2024-07-16 16:15:27 +02:00
#!/usr/bin/env python3.8
2021-06-06 22:08:18 +02:00
import discord
from discord.ext import commands
from jeevesbot import env
import os
import log
import logging.config
from logging import getLogger
2022-11-09 14:10:46 +01:00
import asyncio
2021-06-06 22:08:18 +02:00
# setup root logger handlers
logging.config.dictConfig(log.LOGGING)
2021-06-06 22:08:18 +02:00
# setup logging
log = getLogger(__name__)
# setup discord.py bot
intents = discord.Intents().all()
bot = commands.Bot(command_prefix='!', intents=intents, help_command=None)
2021-06-06 22:08:18 +02:00
e = discord.Embed()
2021-07-09 11:11:09 +02:00
2022-11-09 14:10:46 +01:00
@bot.command(name='load', hidden=True)
@commands.has_permissions(administrator=True)
async def load(ctx, extension):
bot.load_extension(f'cogs.{extension}')
2021-08-12 21:21:22 +02:00
log.info(f'{ctx.message.author} loaded the {extension} module')
2022-11-09 14:10:46 +01:00
@bot.command(name='unload', hidden=True)
@commands.has_permissions(administrator=True)
async def unload(ctx, extension):
bot.unload_extension(f'cogs.{extension}')
2021-08-12 21:21:22 +02:00
log.info(f'{ctx.message.author} unloaded the {extension} module')
2022-11-09 14:10:46 +01:00
@bot.command(name='reload', hidden=True)
@commands.has_permissions(administrator=True)
async def reload(ctx, extension):
bot.unload_extension(f'cogs.{extension}')
bot.load_extension(f'cogs.{extension}')
2021-08-12 21:21:22 +02:00
log.info(f'{ctx.message.author} reloaded the {extension} module')
2022-11-09 14:10:46 +01:00
async def load_extensions():
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
await bot.load_extension(f'cogs.{filename[:-3]}')
@bot.event
2021-06-06 22:08:18 +02:00
async def on_ready():
log.info(f'Active with ID:{bot.user.id} as {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
2022-11-09 14:10:46 +01:00
async def main():
async with bot:
await load_extensions()
await bot.start(env.TOKEN)
2024-07-16 16:15:27 +02:00
asyncio.run(main())