コード例 #1
0
ファイル: setup.py プロジェクト: skylarr1227/skybizzle
    async def sl_info(self, ctx: commands.Context):
        # We don't want embeds for something that will likely be attached to an issue,
        # and doing this also makes what we do to add our info significantly easier.
        f = Future()
        f.set_result(False)
        ctx.embed_requested = lambda *_, **__: f

        send = ctx.send
        debug_info: List[str] = []

        async def send_override(content):
            debug_info.append(content)

        # Closed course, professional driver. Don't attempt this on your own.
        try:
            ctx.send = send_override
            await ctx.invoke(self.bot.get_cog("Core").debuginfo)
        except Exception:
            ctx.send = send
            raise
        else:
            ctx.send = send

        debug_info = [x.replace("```", "").rstrip() for x in debug_info]
        versions = {
            "swift_libs": _sl_version,
            "swift_i18n": maybe_get("swift_i18n.meta", "__version__",
                                    "<unknown>"),
            "motor": maybe_get("motor", "version", "<not installed>"),
        }

        try:
            from redbot.core.drivers import PostgresDriver as _
        except ImportError:
            pass
        else:
            versions["asyncpg"] = maybe_get("asyncpg", "__version__",
                                            "<not installed>")

        debug_info.extend(
            ["", *[f"{k} version: {v}" for k, v in versions.items()]])
        await ctx.send(box("\n".join(debug_info)))
コード例 #2
0
 async def reasonlist(self, ctx: commands.Context):
     """List all configured reasons for warnings"""
     guild = ctx.guild
     guild_settings = self.config.guild(guild)
     msg_list = []
     async with guild_settings.reasons() as registered_reasons:
         for r, v in registered_reasons.items():
             if ctx.embed_requested():
                 em = discord.Embed(
                     title=_("Reason: {name}").format(name=r),
                     description=v["description"])
                 em.add_field(name=_("Points"), value=str(v["points"]))
                 msg_list.append(em)
             else:
                 msg_list.append(
                     "Name: {}\nPoints: {}\nDescription: {}".format(
                         r, v["points"], v["description"]))
     if msg_list:
         await menu(ctx, msg_list, DEFAULT_CONTROLS)
     else:
         await ctx.send(_("There are no reasons configured!"))