From deaba0dde08e1686059f0e86bcc6183711f055b9 Mon Sep 17 00:00:00 2001 From: aikaterna <20862007+aikaterna@users.noreply.github.com> Date: Fri, 4 May 2018 10:19:00 -0700 Subject: [PATCH] Create post.py --- post/post.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 post/post.py diff --git a/post/post.py b/post/post.py new file mode 100644 index 0000000..c4e5a16 --- /dev/null +++ b/post/post.py @@ -0,0 +1,31 @@ +from discord.ext import commands +from .utils import checks + +class Post: + def __init__(self,bot): + self.bot = bot + + @commands.command(no_pm=True, pass_context=True) + @checks.is_owner() + async def postsongs(self, ctx, playlist): + """Posts a playlist.""" + try: + await self.bot.send_file(ctx.message.channel, 'data/audio/playlists/{}/{}.txt'.format(ctx.message.server.id, playlist)) + except FileNotFoundError: + try: + await self.bot.send_file(ctx.message.channel, 'data/audio/playlists/{}.txt'.format(playlist)) + except FileNotFoundError: + await self.bot.say("No playlist named {}.".format(playlist)) + + @commands.command(no_pm=True, pass_context=True) + @checks.is_owner() + async def postcog(self, ctx, cogname): + """Posts a cog.""" + try: + await self.bot.send_file(ctx.message.channel, 'cogs/{}.py'.format(cogname)) + except FileNotFoundError: + await self.bot.say("No cog named {}.".format(cogname)) + +def setup(bot): + n = Post(bot) + bot.add_cog(n)