import time


def get_id(type_identifier: int, counter: int) -> int:
    """
    Generates ID of an object based on the ID counter.

    ID Format: TTTTTTTTinnnnC, where TTTTTTTT is the last 8 digits of
    the UNIX timestamp (seconds accuracy), i is the type identifier
    digit, n is a 4-digit counter (which should be sufficient to avoid
    clashes due to it being larger than the default cache size) and C is
    the check digit, which is just the product of the identifier digit,
    the timestamp, and the counter mod 10.

    The IDs generated by this are at least 4 digits shorter than the
    average Discord Snowflake, but there is a possibility for it to
    generate similar IDs every 3 years or so (hopefully no cache that
    has been configured for this bot is actually that long). It is
    possible to just use Discord's snowflakes instead of this but the
    purpose is to have distinct IDs.

    :param type_identifier: Identifier digit, to be prepended to the ID
    :param counter: Counter from the metaclass
    :return: ID generated from counter
    """
    identifier = type_identifier
    date = int(time.time()) % 100000000
    count = counter + 1
    check = (identifier * date * count) % 10

    # Zeros:       innnnC                 nnnnC            C
    return date * 1000000 + identifier * 100000 + count * 10 + check