Exemplo n.º 1
0
def test_resolve_id_from_role_arg():
    assert resolve_id_from_arg(
        "<@&265858419049758722>",
        ROLE_MENTION_REGEX) == Snowflake(265858419049758722)
    assert resolve_id_from_arg(
        "265858419049758722",
        ROLE_MENTION_REGEX) == Snowflake(265858419049758722)
Exemplo n.º 2
0
def test_resolve_id_from_channel_arg():
    assert resolve_id_from_arg(
        "<#397823614092574721>",
        CHANNEL_MENTION_REGEX) == Snowflake(397823614092574721)
    assert resolve_id_from_arg(
        "397823614092574721",
        CHANNEL_MENTION_REGEX) == Snowflake(397823614092574721)
Exemplo n.º 3
0
async def guild_channel_converter(arg: WrappedArg) -> hikari.GuildChannel:
    if (channel_id := resolve_id_from_arg(arg.data,
                                          CHANNEL_MENTION_REGEX)) is not None:
        if (channel := await _get_or_fetch_guild_channel_from_id(
                arg, channel_id)) is not None and isinstance(
                    channel, hikari.GuildChannel):
            return channel
Exemplo n.º 4
0
async def member_converter(arg: WrappedArg) -> hikari.Member:
    if (user_id := resolve_id_from_arg(arg.data,
                                       USER_MENTION_REGEX)) is not None:
        # noinspection PyProtectedMember
        if (member := arg.context.bot.cache.get_member(arg.context.guild_id,
                                                       user_id)) is not None:
            return member
Exemplo n.º 5
0
def test_resolve_id_from_user_arg():
    assert resolve_id_from_arg(
        "<@!292577213226811392>",
        USER_MENTION_REGEX) == Snowflake(292577213226811392)
    assert resolve_id_from_arg(
        "<@292577213226811392>",
        USER_MENTION_REGEX) == Snowflake(292577213226811392)
    assert resolve_id_from_arg(
        "292577213226811392",
        USER_MENTION_REGEX) == Snowflake(292577213226811392)
Exemplo n.º 6
0
def test_resolve_id_from_faulty_arg():
    assert (resolve_id_from_arg("Hello, this is some random text.",
                                USER_MENTION_REGEX) is None)