diff options
Diffstat (limited to 'bot')
| -rw-r--r-- | bot/bot.py | 8 | ||||
| -rw-r--r-- | bot/cogs/template.py | 27 | ||||
| -rw-r--r-- | bot/constants.py | 1 | 
3 files changed, 26 insertions, 10 deletions
| @@ -1,16 +1,16 @@  from pathlib import Path  from sys import stderr  from traceback import print_exc +from os import environ -from bot import constants  from discord.ext import commands -  bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'))  if __name__ == '__main__': -    cogs = [x.stem for x in Path('cogs').glob('*.py')] +    # Scan for files in the /cogs/ directory and make a list of the file names. +    cogs = [file.stem for file in Path('cogs').glob('*.py')]      for extension in cogs:          try:              bot.load_extension(f'cogs.{extension}') @@ -18,4 +18,4 @@ if __name__ == '__main__':              print(f'Failed to load extension {extension}.', file=stderr)              print_exc() -bot.run(constants.token) +bot.run(environ.get('TOKEN')) diff --git a/bot/cogs/template.py b/bot/cogs/template.py index 18b3f21c..da92f6b5 100644 --- a/bot/cogs/template.py +++ b/bot/cogs/template.py @@ -1,14 +1,31 @@ +from os import system + +  from discord.ext import commands +"""A template cog that contains examples of commands and command groups.""" + +  class Template:      def __init__(self, bot):          self.bot = bot -         -    @commands.command() -    async def template(self, ctx): -        await ctx.send('It indeed is a template cog!') -     +    @commands.command(name='repo', aliases=['repository', 'project'], brief='A link to the repository of this bot.') +    async def repository(self, ctx): +        await ctx.send('https://github.com/discord-python/hacktoberbot') + +    # A command group with the name git. You can now create sub-commands such as git commit. +    @commands.group(name='git', invoke_without_command=True) +    async def github(self, ctx): +        await ctx.send('Resources to learn **Git**: https://try.github.io/.') + +    # A command that belongs to the git command group. Invoked using git commit. +    @github.command() +    async def commit(self, ctx): +        system('git commit -m "A huge commit adding many revolutionary features!"') + + +# Required in order to load the cog, use the class name in the add_cog function.  def setup(bot):      bot.add_cog(Template(bot)) diff --git a/bot/constants.py b/bot/constants.py index f2376c4d..e69de29b 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -1 +0,0 @@ -token = '' | 
