Last active
December 30, 2017 22:48
-
-
Save noirscape/cc8e65c1c42f26af0a9b3780e161817d to your computer and use it in GitHub Desktop.
A minimalist discord bot framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import yaml | |
from discord.ext import commands | |
'''A simple bot framework. | |
Simply configure the options in config.yaml and start the bot with `python3 main.py` | |
Make sure to run requirements.txt first! | |
The bot does -not- have any commands by default. You will either need to add them manually or use the included cog loader. | |
Licensed under the WTFPL (although credit is preferred if you use this as a base)''' | |
config = yaml.safe_load(open('config.yaml')) | |
bot = commands.Bot(command_prefix=commands.when_mentioned_or( | |
config['prefix']), | |
description='A simple bot framework anyone can use', | |
pm_help=True) | |
def load_cog(cog): | |
'''Try to load a cog and fail gracefully if it errors.''' | |
try: | |
bot.load_extension(cog) | |
except Exception as e: | |
print('Could not load cog ' + cog) | |
print(e) | |
@bot.event | |
async def on_ready(): | |
print('------------') | |
print('Logged in as:') | |
print(bot.user.name) | |
print(bot.user.id) | |
print('Using prefix:') | |
print(config['prefix']) | |
print('------------') | |
bot.run(config['token']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
token: #Insert the token here | |
prefix: #Insert the bot prefix here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment