Struct Cacheable<TEntity, TId>
Represents a cached entity.
Inherited Members
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 SourceHasValue
Gets whether this entity is cached.
Declaration
public bool HasValue { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Id
Gets the ID of this entity.
Declaration
public TId Id { get; }
Property Value
| Type | Description |
|---|---|
| TId |
Value
Gets the entity if it could be pulled from cache.
Declaration
public 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 SourceDownloadAsync()
Downloads this entity to cache.
Declaration
public Task<TEntity> DownloadAsync()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TEntity> | A task that represents the asynchronous download operation. The task result contains the downloaded entity. |
Exceptions
| Type | Condition |
|---|---|
| Discord.Net.HttpException | Thrown when used from a user account. |
| System.NullReferenceException | Thrown when the message is deleted. |
GetOrDownloadAsync()
Returns the cached entity if it exists; otherwise downloads it.
Declaration
public Task<TEntity> GetOrDownloadAsync()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.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 |
|---|---|
| Discord.Net.HttpException | Thrown when used from a user account. |
| System.NullReferenceException | Thrown when the message is deleted and is not in cache. |