async def cogs_enable(self, ctx: commands.Context, cog: str): """ Load a cog (folder.file) """ try: self.bot.load_extension(cog) await ctx.send("{} has been enabled.".format(cog)) if USE_REMOTE_CONFIG: edit_remote_config("cogs.txt", cog_to_add=cog) except ExtensionNotFound: try: cog = '{}.py'.format(cog.replace(".", "/")) if USE_DROPBOX: dropbox.download_file(cog) self.bot.load_extension(cog) await ctx.send("{} has been enabled.".format(cog)) except Exception as e: print(e) await ctx.send( "That extension could not be found locally or on Dropbox.") except ExtensionAlreadyLoaded: await ctx.send("Extension already enabled.") except Exception as e: print(e) await ctx.send("Something went wrong.")
def load_remote_config(filename): dropbox.download_file(filename) cogs = [] with open(filename, 'r') as f: for line in f: cogs.append(line.strip()) return cogs
async def cogs_download(self, ctx: commands.Context, cog: str): """ Download a cog from Dropbox """ if USE_DROPBOX: try: cog = '{}.py'.format(cog.replace(".", "/")) if USE_DROPBOX: dropbox.download_file(cog) await ctx.send("{} has been downloaded".format(cog)) except: await ctx.send("Sorry, I couldn't download that file.") else: await ctx.send("Dropbox use is not enabled.")
def download(self, file): if self.USE_DROPBOX and file: return dbx.download_file(file) return False