Struct Cacheable<TCachedEntity, TDownloadableEntity, TRelationship, TId>
- Namespace
- Discord
- Assembly
- Discord.Net.Core.dll
public struct Cacheable<TCachedEntity, TDownloadableEntity, TRelationship, TId> where TCachedEntity : IEntity<TId>, TRelationship where TDownloadableEntity : IEntity<TId>, TRelationship where TId : IEquatable<TId>
Type Parameters
TCachedEntity
TDownloadableEntity
TRelationship
TId
- Inherited Members
Properties
HasValue
Gets whether this entity is cached.
public readonly bool HasValue { get; }
Property Value
Id
Gets the ID of this entity.
public readonly TId Id { get; }
Property Value
- TId
Value
Gets the entity if it could be pulled from cache.
public readonly TCachedEntity Value { get; }
Property Value
- TCachedEntity
Remarks
This value is not guaranteed to be set; in cases where the entity cannot be pulled from cache, it is null.
Methods
DownloadAsync()
Downloads this entity.
public Task<TDownloadableEntity> DownloadAsync()
Returns
- Task<TDownloadableEntity>
A task that represents the asynchronous download operation. The task result contains the downloaded entity.
Exceptions
- HttpException
Thrown when used from a user account.
- NullReferenceException
Thrown when the message is deleted.
GetOrDownloadAsync()
Returns the cached entity if it exists; otherwise downloads it.
public Task<TRelationship> GetOrDownloadAsync()
Returns
- Task<TRelationship>
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
- HttpException
Thrown when used from a user account.
- NullReferenceException
Thrown when the message is deleted and is not in cache.