Search Results for

    Show / Hide Table of Contents

    Struct Cacheable<TEntity, TId>

    Represents a cached entity.

    Namespace: Discord
    Assembly: Discord.Net.Core.dll
    Syntax
    public struct Cacheable<TEntity, TId>
        where TEntity : IEntity<TId> where TId : IEquatable<TId>
    Type Parameters
    Name Description
    TEntity

    The type of entity that is cached.

    TId

    The type of this entity's ID.

    Properties

    | Improve this Doc View Source

    HasValue

    Gets whether this entity is cached.

    Declaration
    public readonly bool HasValue { get; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    Id

    Gets the ID of this entity.

    Declaration
    public readonly TId Id { get; }
    Property Value
    Type Description
    TId
    | Improve this Doc View Source

    Value

    Gets the entity if it could be pulled from cache.

    Declaration
    public readonly TEntity Value { get; }
    Property Value
    Type Description
    TEntity
    Remarks

    This value is not guaranteed to be set; in cases where the entity cannot be pulled from cache, it is null.

    Methods

    | Improve this Doc View Source

    DownloadAsync()

    Downloads this entity to cache.

    Declaration
    public async Task<TEntity> DownloadAsync()
    Returns
    Type Description
    Task<TEntity>

    A task that represents the asynchronous download operation. The task result contains the downloaded entity.

    Exceptions
    Type Condition
    HttpException

    Thrown when used from a user account.

    | Improve this Doc View Source

    GetOrDownloadAsync()

    Returns the cached entity if it exists; otherwise downloads it.

    Declaration
    public async Task<TEntity> GetOrDownloadAsync()
    Returns
    Type Description
    Task<TEntity>

    A task that represents the asynchronous operation that attempts to get the message via cache or to download the message. The task result contains the downloaded entity.

    Exceptions
    Type Condition
    HttpException

    Thrown when used from a user account.

    Theme

    • Improve this Doc
    • View Source
    In This Article
    Back to top Discord.Net (c) 2015-2022 3.6.0