Add custom help command

This commit is contained in:
Joshua Arulsamy 2020-08-13 02:52:22 -06:00
parent 08a235d55e
commit 228c2b480b
2 changed files with 40 additions and 4 deletions

View File

@ -29,6 +29,8 @@ plex_log.setLevel(config["plex"]["log_level"])
bot_log.setLevel(config["discord"]["log_level"]) bot_log.setLevel(config["discord"]["log_level"])
bot = Bot(command_prefix=BOT_PREFIX) bot = Bot(command_prefix=BOT_PREFIX)
# Remove help command, we have our own custom one.
bot.remove_command("help")
bot.add_cog(General(bot)) bot.add_cog(General(bot))
bot.add_cog(Plex(bot, BASE_URL, PLEX_TOKEN, LIBRARY_NAME, BOT_PREFIX)) bot.add_cog(Plex(bot, BASE_URL, PLEX_TOKEN, LIBRARY_NAME, BOT_PREFIX))
bot.run(TOKEN) bot.run(TOKEN)

View File

@ -19,6 +19,24 @@ root_log = logging.getLogger()
plex_log = logging.getLogger("Plex") plex_log = logging.getLogger("Plex")
bot_log = logging.getLogger("Bot") bot_log = logging.getLogger("Bot")
help_text = """
General:
kill [silent] - Halt the bot [silently].
help - Print this help message.
cleanup - Delete old messages from the bot.
Plex:
play <SONG_NAME> - Play a song from the plex server.
album <ALBUM_NAME> - Queue an entire album to play.
np - Print the current playing song.
stop - Halt playback and leave vc.
pause - Pause playback.
resume - Resume playback.
clear - Clear play queue.
[] - Optional args.
"""
class General(commands.Cog): class General(commands.Cog):
"""General commands """General commands
@ -60,6 +78,22 @@ class General(commands.Cog):
await self.bot.close() await self.bot.close()
bot_log.info("Stopping upon the request of %s", ctx.author.mention) bot_log.info("Stopping upon the request of %s", ctx.author.mention)
@command(name="help")
async def help(self, ctx):
"""Prints command help
Args:
ctx: discord.ext.commands.Context message context from command
Returns:
None
Raise:
None
"""
await ctx.send(f"```{help_text}```")
@command() @command()
async def cleanup(self, ctx, limit=250): async def cleanup(self, ctx, limit=250):
"""Delete old messages from bot """Delete old messages from bot
@ -91,11 +125,11 @@ class General(commands.Cog):
class Plex(commands.Cog): class Plex(commands.Cog):
"""Discord commands pertinent to interacting with Plex """
Discord commands pertinent to interacting with Plex
Contains user commands such as play, pause, resume, stop, etc.
Grabs, and parses all data from plex database.
Contains user commands such as play, pause, resume, stop, etc.
Grabs, and parses all data from plex database.
""" """
# pylint: disable=too-many-instance-attributes # pylint: disable=too-many-instance-attributes