Example #1
0
    async def allupdate(self, ctx):
        await ctx.trigger_typing()
        await ctx.send("Updating source code...")
        for file in os.listdir("cogs"):
            if file.endswith(".py"):
                name = file[:-3]
                link = "https://raw.githubusercontent.com/Shio7/Keter/master/cogs/" + name + ".py"
                r = requests.get(link, allow_redirects=True)
                if os.path.isfile('./cogs/' + name + ".py"):
                    try:
                        self.bot.unload_extension(f"cogs.{name}")
                    except Exception as e:
                        return await ctx.send(default.traceback_maker(e))
                    await ctx.send(f"Unloaded extension **{name}.py**")
                    os.remove('./cogs/' + name + ".py")
                    open('./cogs/' + name + ".py", 'wb').write(r.content)
                else:
                    open('./cogs/' + name + ".py", 'wb').write(r.content)
                await ctx.send("Updated: " + name + ".py")

                try:
                    self.bot.load_extension(f"cogs.{name}")
                except Exception as e:
                    return await ctx.send(default.traceback_maker(e))
                await ctx.send(f"Loaded extension **{name}.py**")
        await ctx.send("All modules updated")
Example #2
0
 async def reload(self, ctx, name: str):
     """ Reloads an extension. """
     try:
         self.bot.reload_extension(f"cogs.{name}")
     except Exception as e:
         return await ctx.send(default.traceback_maker(e))
     await ctx.send(f"Reloaded extension **{name}.py**")
Example #3
0
    async def on_command_error(self, ctx, err):
        if isinstance(err, errors.MissingRequiredArgument) or isinstance(err, errors.BadArgument):
            helper = str(ctx.invoked_subcommand) if ctx.invoked_subcommand else str(ctx.command)
            await ctx.send_help(helper)

        elif isinstance(err, errors.CommandInvokeError):
            error = default.traceback_maker(err.original)

            if "2000 or fewer" in str(err) and len(ctx.message.clean_content) > 1900:
                return await ctx.send(
                    f"You attempted to make the command display more than 2,000 characters...\n"
                    f"Both error and command will be ignored."
                )

            await ctx.send(f"There was an error processing the command ;-;\n{error}")

        elif isinstance(err, errors.CheckFailure):
            pass

        elif isinstance(err, errors.MaxConcurrencyReached):
            await ctx.send(f"You have reached the maximum command usage. Please wait.")

        elif isinstance(err, errors.CommandOnCooldown):
            await ctx.send(f"This command is on cooldown... try again in {err.retry_after:.2f} seconds.")

        elif isinstance(err, errors.CommandNotFound):
            pass
Example #4
0
    async def 다운로드(self, ctx, *, content:str):
        content = content.split()
        embed = discord.Embed(title="관리모듈 A1", description=content[2] + "모듈을 다운로드 하시겠습니까?", color=0xeff0f1)
        embed.set_footer(icon_url=ctx.author.avatar_url,
                         text=ctx.author.name + "#" + ctx.author.discriminator + " " + str(
                             datetime.today().strftime('%Y-%m-%d %H:%M:%S')))
        msg = await ctx.send(embed=embed)

        def reaction_check_(m):
            if m.message_id == msg.id and m.user_id == ctx.author.id and str(m.emoji) == "✅":
                return True
            return False

        try:
            await msg.add_reaction("✅")
            await self.bot.wait_for('raw_reaction_add', timeout=10.0, check=reaction_check_)
            await ctx.trigger_typing()
            try:
                r = requests.get(content[0], allow_redirects=True)

                if os.path.isfile(content[1] + content[2] + ".py"):
                    embed = discord.Embed(title="관리모듈 A1",
                                        description=content[2] + "모듈이 이미 있어요. `업데이트` 커맨드를 사용해 주세요.",
                                        color=0xeff0f1)
                    embed.set_footer(icon_url=ctx.author.avatar_url,
                                         text=ctx.author.name + "#" + ctx.author.discriminator + " " + str(
                                             datetime.today().strftime('%Y-%m-%d %H:%M:%S')))
                    msg = await ctx.send(embed=embed)

                else:
                    open(content[1] + content[2] + ".py", 'wb').write(r.content)
                    try:
                        self.bot.load_extension(f"cogs.{content[2]}")
                    except Exception as e:
                        return await ctx.send(default.traceback_maker(e))
                    embed = discord.Embed(title="관리모듈 A1",
                                          description=content[2] + "모듈 다운로드 완료! 로드까지도 완료했어요!",
                                          color=0xeff0f1)
                    embed.set_footer(icon_url=ctx.author.avatar_url,
                                     text=ctx.author.name + "#" + ctx.author.discriminator + " " + str(
                                         datetime.today().strftime('%Y-%m-%d %H:%M:%S')))
                    msg = await ctx.send(embed=embed)

            except:
                embed = discord.Embed(title="관리모듈 A1", description="에러 발생!",
                                      color=0xeff0f1)
                embed.set_footer(icon_url=ctx.author.avatar_url,
                                 text=ctx.author.name + "#" + ctx.author.discriminator + " " + str(
                                     datetime.today().strftime('%Y-%m-%d %H:%M:%S')))
                embed.set_thumbnail(url=parfait_url)
                msg = await ctx.send(embed=embed)

        except:
            await msg.delete()
            embed = discord.Embed(title="관리모듈 A1", description="동의하지 않으셨습니다.", color=0xeff0f1)
            embed.set_footer(icon_url=ctx.author.avatar_url,
                             text=ctx.author.name + "#" + ctx.author.discriminator + " " + str(
                                 datetime.today().strftime('%Y-%m-%d %H:%M:%S')))
            await ctx.send(embed=embed)
Example #5
0
 async def 지우기(self, ctx, filename: str):
     if os.path.isfile('./cogs/' + filename + ".py"):
         try:
             self.bot.unload_extension(f"cogs.{filename}")
         except Exception as e:
             return await ctx.send(default.traceback_maker(e))
         await ctx.send(f"Unloaded extension **{filename}.py**")
         os.remove('./cogs/' + filename + ".py")
         await ctx.send(f"**{filename}.py** 삭제완료")
     else:
         await ctx.send(f"**{filename}.py 찾을 수 없음**")
Example #6
0
 async def update(self, ctx, filename: str):
     await ctx.trigger_typing()
     await ctx.send("Updating source code...")
     link = "https://raw.githubusercontent.com/Shio7/Keter/master/cogs/" + filename + ".py"
     r = requests.get(link, allow_redirects=True)
     if os.path.isfile('./cogs/' + filename + ".py"):
         try:
             self.bot.unload_extension(f"cogs.{filename}")
         except Exception as e:
             return await ctx.send(default.traceback_maker(e))
         await ctx.send(f"Unloaded extension **{filename}.py**")
         os.remove('./cogs/' + filename + ".py")
         open('./cogs/' + filename + ".py", 'wb').write(r.content)
     else:
         open('./cogs/' + filename + ".py", 'wb').write(r.content)
     await ctx.send("Updated: " + filename + ".py")
     """ Loads an extension. """
     try:
         self.bot.load_extension(f"cogs.{filename}")
     except Exception as e:
         return await ctx.send(default.traceback_maker(e))
     await ctx.send(f"Loaded extension **{filename}.py**")
Example #7
0
 async def reloadevs(self, ctx, name: str):
     """ Reloads a evs module. """
     name_maker = f"evs/{name}.py"
     try:
         module_name = importlib.import_module(f"evs.{name}")
         importlib.reload(module_name)
     except ModuleNotFoundError:
         return await ctx.send(
             f"Couldn't find module named **{name_maker}**")
     except Exception as e:
         error = default.traceback_maker(e)
         return await ctx.send(
             f"Module **{name_maker}** returned error and was not reloaded...\n{error}"
         )
     await ctx.send(f"Reloaded module **{name_maker}**")
Example #8
0
    async def 지우기(self, ctx, filename:str):
        embed = discord.Embed(title="관리모듈 A1", description=filename + "모듈을 지우시겠습니까?", color=0xeff0f1)
        embed.set_footer(icon_url=ctx.author.avatar_url,
                         text=ctx.author.name + "#" + ctx.author.discriminator + " " + str(
                             datetime.today().strftime('%Y-%m-%d %H:%M:%S')))
        msg = await ctx.send(embed=embed)

        def reaction_check_(m):
            if m.message_id == msg.id and m.user_id == ctx.author.id and str(m.emoji) == "✅":
                return True
            return False

        try:
            await msg.add_reaction("✅")
            await self.bot.wait_for('raw_reaction_add', timeout=10.0, check=reaction_check_)
            await ctx.trigger_typing()

            if os.path.isfile('./cogs/' + filename + ".py"):
                try:
                    self.bot.unload_extension(f"cogs.{filename}")
                except Exception as e:
                    return await ctx.send(default.traceback_maker(e))
                os.remove('./cogs/' + filename + ".py")
                embed = discord.Embed(title="관리모듈 A1", description=filename + ".py 삭제 완료!",
                                      color=0xeff0f1)
                embed.set_footer(icon_url=ctx.author.avatar_url,
                                 text=ctx.author.name + "#" + ctx.author.discriminator + " " + str(
                                     datetime.today().strftime('%Y-%m-%d %H:%M:%S')))
                embed.set_thumbnail(url=parfait_url)
                msg = await ctx.send(embed=embed)

            else:
                embed = discord.Embed(title="관리모듈 A1", description="에러 발생!",
                                      color=0xeff0f1)
                embed.set_footer(icon_url=ctx.author.avatar_url,
                                 text=ctx.author.name + "#" + ctx.author.discriminator + " " + str(
                                     datetime.today().strftime('%Y-%m-%d %H:%M:%S')))
                embed.set_thumbnail(url=parfait_url)
                msg = await ctx.send(embed=embed)

        except:
            await msg.delete()
            embed = discord.Embed(title="관리모듈 A1", description="동의하지 않으셨습니다.", color=0xeff0f1)
            embed.set_footer(icon_url=ctx.author.avatar_url,
                             text=ctx.author.name + "#" + ctx.author.discriminator + " " + str(
                                 datetime.today().strftime('%Y-%m-%d %H:%M:%S')))
            await ctx.send(embed=embed)
Example #9
0
    async def reloadall(self, ctx):
        """ Reloads all extensions. """
        error_collection = []
        for file in os.listdir("cogs"):
            if file.endswith(".py"):
                name = file[:-3]
                try:
                    self.bot.reload_extension(f"cogs.{name}")
                except Exception as e:
                    error_collection.append(
                        [file, default.traceback_maker(e, advance=False)])

        if error_collection:
            output = "\n".join(
                [f"**{g[0]}** ```diff\n- {g[1]}```" for g in error_collection])
            return await ctx.send(
                f"Attempted to reload all extensions, was able to reload, "
                f"however the following failed...\n\n{output}")

        await ctx.send("Successfully reloaded all extensions")