Ejemplo n.º 1
0
class Command(TableBase, table_name='commands'):
    id = asyncqlio.Column(asyncqlio.Serial, primary_key=True)
    guild_id = asyncqlio.Column(asyncqlio.BigInt, index=True, nullable=True)
    commands_guild_id_idx = asyncqlio.Index(guild_id)

    channel_id = asyncqlio.Column(asyncqlio.BigInt)
    author_id = asyncqlio.Column(asyncqlio.BigInt, index=True)
    commands_author_id_idx = asyncqlio.Index(author_id)

    used = asyncqlio.Column(asyncqlio.Timestamp)
    prefix = asyncqlio.Column(asyncqlio.String)
    command = asyncqlio.Column(asyncqlio.String, index=True)
    commands_command_idx = asyncqlio.Index(command)
Ejemplo n.º 2
0
class Category(TableBase, table_name='trivia_categories'):
    id = asyncqlio.Column(asyncqlio.Serial, primary_key=True)
    guild_id = asyncqlio.Column(asyncqlio.BigInt)
    guild_id_idx = asyncqlio.Index(guild_id)

    name = asyncqlio.Column(asyncqlio.String(256))
    description = asyncqlio.Column(asyncqlio.String(512), nullable=True)

    # ---------Converter stuffs------------

    _default_categories = {}

    @classmethod
    async def convert(cls, ctx, arg):
        lowered = arg.lower()
        with contextlib.suppress(KeyError):
            return cls._default_categories[lowered]

        query = ctx.session.select.from_(cls).where(
            (cls.guild_id == ctx.guild.id)
            & (cls.name == lowered))
        result = await query.first()
        if result is None:
            raise commands.BadArgument(
                f"Category {lowered} doesn't exist... :(")

        return result
Ejemplo n.º 3
0
class Alias(_Table, table_name='command_aliases'):
    id = asyncqlio.Column(asyncqlio.Serial, primary_key=True)

    guild_id = asyncqlio.Column(asyncqlio.BigInt, index=True)
    alias = asyncqlio.Column(asyncqlio.String(2000), index=True)
    command = asyncqlio.Column(asyncqlio.String(2000))

    alias_idx = asyncqlio.Index(guild_id, alias, unique=True)
Ejemplo n.º 4
0
class _Schedule(_Table, table_name='schedule'):
    id = asyncqlio.Column(asyncqlio.Serial, primary_key=True)
    expires = asyncqlio.Column(asyncqlio.Timestamp)
    schedule_expires_idx = asyncqlio.Index(expires)

    event = asyncqlio.Column(asyncqlio.String)
    created = asyncqlio.Column(asyncqlio.Timestamp)
    args_kwargs = asyncqlio.Column(dbtypes.JSON, default="'{}'::jsonb")
Ejemplo n.º 5
0
class CommandPermissions(_Table, table_name='permissions'):
    id = asyncqlio.Column(asyncqlio.Serial, primary_key=True)

    guild_id = asyncqlio.Column(asyncqlio.BigInt, index=True)
    permissions_guild_id_idx = asyncqlio.Index(guild_id)
    snowflake = asyncqlio.Column(asyncqlio.BigInt, nullable=True)

    name = asyncqlio.Column(asyncqlio.String)
    whitelist = asyncqlio.Column(asyncqlio.Boolean)
Ejemplo n.º 6
0
class Question(TableBase, table_name='trivia_questions'):
    id = asyncqlio.Column(asyncqlio.Serial, primary_key=True)
    category_id = asyncqlio.Column(asyncqlio.Integer,
                                   foreign_key=asyncqlio.ForeignKey(
                                       Category.id))
    category_id_idx = asyncqlio.Index(category_id)

    question = asyncqlio.Column(asyncqlio.String(1024))
    answer = asyncqlio.Column(asyncqlio.String(512))
    image = asyncqlio.Column(asyncqlio.String(512), nullable=True)
Ejemplo n.º 7
0
class MinesweeperGame(TableBase, table_name='minesweeper_games'):
    id = asyncqlio.Column(asyncqlio.Serial, primary_key=True)

    level = asyncqlio.Column(asyncqlio.SmallInt)
    won = asyncqlio.Column(asyncqlio.Boolean)

    guild_id = asyncqlio.Column(asyncqlio.BigInt)
    user_id = asyncqlio.Column(asyncqlio.BigInt)
    played_at = asyncqlio.Column(asyncqlio.Timestamp)

    time = asyncqlio.Column(asyncqlio.Real)
    minesweeper_time_idx = asyncqlio.Index(time)
Ejemplo n.º 8
0
class Case(TableBase, table_name='modlog'):
    id = asyncqlio.Column(asyncqlio.Serial, primary_key=True)
    channel_id = asyncqlio.Column(asyncqlio.BigInt)
    message_id = asyncqlio.Column(asyncqlio.BigInt)

    guild_id = asyncqlio.Column(asyncqlio.BigInt)
    modlog_guild_id_idx = asyncqlio.Index(guild_id)

    action = asyncqlio.Column(asyncqlio.String(16))
    mod_id = asyncqlio.Column(asyncqlio.BigInt)
    reason = asyncqlio.Column(asyncqlio.String(1024))

    # Can either be the duration, in the case of a mute or tempban,
    # or the role, in the case of a special role.
    extra = asyncqlio.Column(asyncqlio.Text, default='{}')