def setup(bot): bot.add_cog(Commands(bot)) # Get keys from config file cfload.read('../config.ini') keys = cfload.configSectionMap('Merriam Webster API') bot.add_cog(Dictionary(bot, keys['dictionary_key'], keys['thesaurus_key']))
async def shutdown(self, ctx): """Shuts down the bot.""" if ctx.author.id == int( cfload.configSectionMap('Owner Credentials')['owner_id']): await ctx.message.add_reaction('\U0001F50C') # Power plug emoji await self.bot.logout() else: await ctx.message.add_reaction('\U0000274C') # Cross mark await ctx.send("You can't shut me down.", delete_after=15)
def __init__(self, bot): self.bot = bot # Set up reddit client self.reddit_credentials = cfload.configSectionMap("Reddit API") self.reddit = praw.Reddit( client_id=self.reddit_credentials['client_id'], client_secret=self.reddit_credentials['client_secret'], user_agent=self.reddit_credentials['user_agent'], username=self.reddit_credentials['username'], password=self.reddit_credentials['password'])
import discord from discord.ext import commands import configloader as cfload from logger import Logger as log log.info('Reading config data...') cfload.read('../config.ini') ####################### Begin Loading Process ################################ startup_extensions = cfload.configSectionMap( 'Startup')['startup_extensions'].split() command_prefix = cfload.configSectionMap('Commands')['command_prefix'] # Add gateway intents for members. intents = discord.Intents.default() # All but the two privileged ones intents.members = True # Subscribe to the Members intent bot = commands.Bot( command_prefix=commands.when_mentioned_or(command_prefix), description=cfload.configSectionMap('Startup')['description'], case_insensitive=True, intents=intents) # Load extensions if __name__ == '__main__': log.info('\nLoading extensions...') for extension in startup_extensions: try: bot.load_extension(extension) log.info(f'Extension \'{extension}\' loaded.')
""" import random from io import BytesIO import discord import praw import qrcode import requests from discord.ext import commands import configloader as cfload from logger import Logger as log cfload.read('..\\config.ini') # TODO maybe move this to the setup function? log.info( cfload.configSectionMap("Owner Credentials")['owner_id'], "is the owner. Only this user can use /shutdown.") class Commands(commands.Cog): """Various commands""" prune_cutoff = 25 def __init__(self, bot): self.bot = bot # Set up reddit client self.reddit_credentials = cfload.configSectionMap("Reddit API") self.reddit = praw.Reddit( client_id=self.reddit_credentials['client_id'], client_secret=self.reddit_credentials['client_secret'], user_agent=self.reddit_credentials['user_agent'],
def setup(bot): prefix = cfload.configSectionMap('Commands')['command_prefix'] bot.add_cog(Chameleon(bot, prefix))
def setup(bot): admin_id = cfload.configSectionMap('Owner Credentials')['owner_id'] bot.add_cog(Music(bot, admin_id))