Пример #1
0
 async def _welcome(self, ctx, *, users: discord.User = None):
     """A basic welcome command"""
     if not users:
         await ctx.send(f"Welcome {ctx.author.mention} to {ctx.guild.name}!"
                        )
     else:
         if len(users) > 1:
             users = humanize_list(users)
         else:
             users = users[0].mention
         await ctx.send(f"Welcome {users} to {ctx.guild.name}!")
Пример #2
0
 async def _unload(self, ctx, *cogs: str):
     """Unload cogs."""
     if not cogs:
         return await ctx.send("Please call with cogs to unload.")
     unloaded_cogs = []
     errors = []
     for cog in cogs:
         try:
             ctx.bot.unload_extension(f"cogs.{cog.lower()}")
             unloaded_cogs.append(cog.capitalize())
         except Exception as e:
             errors.append(e)
     unloaded_cogs = humanize_list(unloaded_cogs)
     if len(unloaded_cogs) > 0:
         await ctx.send(f"Unloaded: {unloaded_cogs}")
     if len(errors) > 0:
         await ctx.send(f"Errors: {errors}")
Пример #3
0
 async def _load(self, ctx, *cogs: str):
     """Loads cogs."""
     if not cogs:
         return await ctx.send("Please call with cogs to load.")
     loaded_cogs = []
     errors = []
     for cog in cogs:
         try:
             ctx.bot.load_extension(f"cogs.{cog.lower()}")
             loaded_cogs.append(cog.capitalize())
         except Exception as e:
             errors.append(e)
     loaded_cogs = humanize_list(loaded_cogs)
     if len(loaded_cogs) > 0:
         await ctx.send(f"Loaded: {loaded_cogs}")
     if len(errors) > 0:
         await ctx.send("Errors: {}".format("\n".join(errors)))
Пример #4
0
def loadallcogs():
    # loads cogs
    loaded = []
    errors = []
    ignore = ["Utils", "Auditlogs"]
    for cog in os.listdir("cogs"):
        if cog.endswith("py"):
            filename = cog[:-3]
            cog = filename.capitalize()
            if cog is None or cog in ignore:
                continue
            try:
                bot.load_extension(f"cogs.{filename}")
                loaded.append(cog)
            except Exception as e:
                errors.append(e)

    loaded = humanize_list(loaded)
    print(f"Loaded: {loaded}")
    if len(errors) > 0:
        print(f"Errors: {errors}")