예제 #1
0
 async def ListRemove(self, ctx, Number):
     'Removes Items From TODO List'
     try:
         Filename = await GetActiveName(ctx.author.id)
         with open(f"{Filename}", "r+") as f:
             content = f.readlines()
             if await IDCheck(ctx.author.id): raise (IdError)
             if await FileEmptyCheck(content, ctx): raise (FileEmpty)
             if await ParameterEmptyCheck(Number, ctx):
                 raise (ParameterEmpty)
             if await IntCheck(Number): raise (ValueError)
             line = content[int(Number) - 1]
             content.remove(line)
             f.seek(0)
             f.truncate()
             for _ in content:
                 _.strip("\n")
                 f.write(f"{_}")
             if line in content:
                 await ctx.send(f"Error Recieved")
             else:
                 await ctx.send(f"Removed `{Number} : {str(line)}`")
     except (FileEmpty, ParameterEmpty, ValueError, IndexError,
             IdError) as Exc:
         logger.debug(f"Caught `{type(Exc)}` in `{ctx.command}`")
         if type(Exc) == IdError:
             await ctx.send("You aren't permitted to use this command.")
         elif type(Exc) == IndexError:
             await ctx.send(
                 f"This Component Does Not Exist in The List : `{str(Number)}`"
             )
         elif type(Exc) == ValueError:
             await ctx.send(f"Parameter `{Number}` is not an Integer")
     except (Exception) as Exc:
         pass
예제 #2
0
 async def Create(self, ctx, name="Main"):
     'Setup for a user\'s to do list'
     if os.path.isdir(f"Lists/{ctx.author.id}"):
         try:
             if name == "Main":
                 with open(f"Lists/{ctx.author.id}/Active.txt",
                           "+a") as ActiveFile:
                     ActiveFile.write(f"{name}-{ctx.author.id}.ToDo")
                     logger.debug(
                         f"instantiated Active File for {ctx.author}")
             FileName = f"Lists/{ctx.author.id}/{name}-{ctx.author.id}.ToDo"
             if os.path.isfile(FileName):
                 await ctx.send(
                     f"List Already Exists under name `{FileName}` ")
                 return ()
             file = open(FileName, "+a")
             await ctx.send(f"List Created Under Name `{FileName}`")
         except (Exception) as Exc:
             logger.info(f"{Exc}")
     else:
         os.mkdir(f"Lists/{ctx.author.id}")
         await ctx.send(
             "Your Folder has been created, please re-run command.")
예제 #3
0
def setup(bot):
    logger.debug("| Loaded Poll | ")
    bot.add_cog(Fun(bot))
예제 #4
0
def teardown(bot):
    logger.debug("| Unloaded Admin | ")
    bot.remove_cog(Admin(bot))
예제 #5
0
def setup(bot):
    logger.debug("| Loaded Admin | ")
    bot.add_cog(Admin(bot))
예제 #6
0
def teardown(bot):
    logger.debug("| Unloaded ToDoList | ")
    bot.remove_cog(ToDoList(bot))
예제 #7
0
def setup(bot):
    logger.debug("| Loaded ToDoList | ")
    bot.add_cog(ToDoList(bot))