def edit_remote_config(filename, cog_to_add=None, cog_to_remove=None): current_cogs = load_remote_config(filename) if cog_to_add and cog_to_add not in current_cogs: current_cogs.append(cog_to_add) if cog_to_remove and cog_to_remove in current_cogs: current_cogs.remove(cog_to_remove) with open(filename, 'w') as f: for cog in current_cogs: f.write(cog + "\n") dropbox.upload_file(filename)
async def cogs_upload(self, ctx: commands.Context, cog: str): """ Upload a local cog to Dropbox """ if USE_DROPBOX: try: path = cog.replace(".", "/") folderPath = '/'.join(path.split('/')[:-1]) if dropbox.create_folder_path(folderPath): cog = '{}.py'.format(path) print(cog) dropbox.upload_file(cog, rename=cog) await ctx.send("{} has been uploaded".format(cog)) else: await ctx.send( "Sorry, something went wrong creating the folder path on Dropbox." ) except Exception as e: print(e) await ctx.send("Sorry, I couldn't upload that file.") else: await ctx.send("Dropbox use is not enabled.")
def backup(self, file, rename=False): if self.USE_DROPBOX and file: return dbx.upload_file(filePath=file, rename=rename) return False
def upload(self, file): if self.USE_DROPBOX and file: return dbx.upload_file(file) return False