Remora.Discord.Interactivity
3.0.10
Prefix Reserved
See the version list below for details.
dotnet add package Remora.Discord.Interactivity --version 3.0.10
NuGet\Install-Package Remora.Discord.Interactivity -Version 3.0.10
<PackageReference Include="Remora.Discord.Interactivity" Version="3.0.10" />
paket add Remora.Discord.Interactivity --version 3.0.10
#r "nuget: Remora.Discord.Interactivity, 3.0.10"
// Install Remora.Discord.Interactivity as a Cake Addin #addin nuget:?package=Remora.Discord.Interactivity&version=3.0.10 // Install Remora.Discord.Interactivity as a Cake Tool #tool nuget:?package=Remora.Discord.Interactivity&version=3.0.10
Remora.Discord.Interactivity
This package provides a framework for creating interaction-driven entities using Discord's message components.
Structure
The library's design revolves around an MVC-like architecture, where your application provides and drives the model and controller, while Discord serves as the view.
A controller is implemented by creating a class that implements
IInteractiveEntity
, which in turn may access data from an arbitrary model of
your choice (EF Core, in-memory data, external APIs, etc). This entity is then
instantiated and invoked when your application receives a component interaction,
and declares its interest in the interaction based on contextual data.
Interested entities (of which there may be several) are then allowed to perform their implemented functionality in order to update the model or view.
Usage
First, add the required services to the dependency injection container.
services.AddInteractivity();
In order to respond to incoming component interactions, declare a class that
implements one or more interfaces related to the component type the entity
wishes to provide business logic for (such as IButtonInteractiveEntity
,
ISelectMenuInteractiveEntity
, or IModalInteractiveEntity
).
Entities are transient services, so you may inject any other dependencies in normal fashion.
public class MyEntity : IButtonInteractiveEntity
{
public Task<Result<bool>> IsInterestedAsync(ComponentType? componentType, string customID, CancellationToken ct = default)
{
// ...
}
public Task<Result> HandleInteractionAsync(IUser user, string customID, CancellationToken ct = default)
{
// ...
}
}
These entities must then be registered with your dependency injection container.
services.AddInteractiveEntity<MyEntity>();
External model
If your controller manipulates data from an external model, it is up to you to appropriately synchronize access or inject relevant services into the entity.
In-memory model
If your controller only has simple needs, a built-in in-memory model may be used, wherein access to a shared object is controlled by Remora. Entities that wish to access the same in-memory model are executed sequentially, and changes made to the object are propagated between each entity.
Entities which wish to use this in-memory model must inherit from
InMemoryPersistentInteractiveEntity<TData>
, and messages associated with these
entities must be sent via the InteractiveMessageService
where an initial model
state is provided.
public class MyInMemoryEntity : InMemoryPersistentInteractiveEntity, IButtonInteractiveEntity
{
public string Nonce => _myContextualInformation.Nonce;
public Task<Result<bool>> IsInterestedAsync(ComponentType? componentType, string customID, CancellationToken ct = default)
{
// ...
}
public Task<Result> HandleInteractionAsync(IUser user, string customID, CancellationToken ct = default)
{
// ...
this.Data.DoSomething();
}
}
The Nonce
property is used to identify which shared object the entity wishes
to act upon, and is usually formed from contextual information injected into the
entity (such as a guild, channel, user, or message ID).
If the shared object should be deleted after the entity has finished executing,
you may set the DeleteData
property to true
.
Note that the shared objects are not deleted automatically, and do not have a set lifetime. If you do not flag them for deletion at some point, they will persist indefinitely.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.Extensions.Caching.Memory (>= 6.0.1)
- Remora.Discord.Commands (>= 20.2.0)
- Remora.Discord.Gateway (>= 8.0.4)
-
net5.0
- Microsoft.Extensions.Caching.Memory (>= 6.0.1)
- Remora.Discord.Commands (>= 20.2.0)
- Remora.Discord.Gateway (>= 8.0.4)
-
net6.0
- Microsoft.Extensions.Caching.Memory (>= 6.0.1)
- Remora.Discord.Commands (>= 20.2.0)
- Remora.Discord.Gateway (>= 8.0.4)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Remora.Discord.Interactivity:
Package | Downloads |
---|---|
Remora.Discord
Metapackage for Remora.Discord's various components |
|
Remora.Discord.Extensions
Utilities and components which extend upon Remora.Discord's base resources |
|
Remora.Discord.Pagination
Button-based pagination of messages for Remora.Discord |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
5.0.0 | 12,326 | 9/21/2024 |
4.5.4 | 22,551 | 5/28/2024 |
4.5.3 | 25,231 | 2/5/2024 |
4.5.2 | 14,244 | 11/14/2023 |
4.5.1 | 29,193 | 7/24/2023 |
4.5.0 | 18,520 | 5/11/2023 |
4.4.6 | 1,820 | 3/20/2023 |
4.4.5 | 2,237 | 1/19/2023 |
4.4.4 | 1,614 | 1/10/2023 |
4.4.3 | 1,929 | 12/28/2022 |
4.4.2 | 1,318 | 12/13/2022 |
4.4.1 | 1,008 | 12/13/2022 |
4.4.0 | 1,024 | 12/10/2022 |
4.3.0 | 1,563 | 10/30/2022 |
4.2.6 | 16,816 | 9/2/2022 |
4.2.5 | 1,437 | 8/19/2022 |
4.2.4 | 1,593 | 7/28/2022 |
4.2.3 | 1,459 | 7/26/2022 |
4.2.2 | 1,324 | 7/26/2022 |
4.2.1 | 1,863 | 6/30/2022 |
4.2.0 | 1,362 | 6/30/2022 |
4.1.0 | 1,293 | 6/29/2022 |
4.0.0 | 1,356 | 6/27/2022 |
3.0.26 | 1,440 | 6/23/2022 |
3.0.25 | 1,923 | 6/20/2022 |
3.0.24 | 1,380 | 6/19/2022 |
3.0.23 | 1,336 | 6/18/2022 |
3.0.22 | 1,471 | 6/14/2022 |
3.0.21 | 1,396 | 6/8/2022 |
3.0.20 | 1,392 | 6/3/2022 |
3.0.19 | 1,411 | 5/25/2022 |
3.0.18 | 1,430 | 5/23/2022 |
3.0.17 | 1,523 | 5/15/2022 |
3.0.16 | 1,423 | 5/10/2022 |
3.0.15 | 1,382 | 5/9/2022 |
3.0.14 | 1,373 | 5/8/2022 |
3.0.13 | 1,457 | 5/3/2022 |
3.0.12 | 1,731 | 4/28/2022 |
3.0.11 | 1,364 | 4/28/2022 |
3.0.10 | 1,378 | 4/25/2022 |
3.0.9 | 1,818 | 4/18/2022 |
3.0.8 | 1,389 | 4/18/2022 |
3.0.7 | 1,552 | 4/2/2022 |
3.0.6 | 1,401 | 4/2/2022 |
3.0.5 | 1,448 | 3/21/2022 |
3.0.4 | 1,430 | 3/17/2022 |
3.0.3 | 1,345 | 3/15/2022 |
3.0.2 | 1,820 | 2/20/2022 |
3.0.1 | 1,334 | 2/20/2022 |
3.0.0 | 1,414 | 2/19/2022 |
3.0.0-rc1 | 671 | 2/14/2022 |
2.0.0 | 1,417 | 2/14/2022 |
1.0.4 | 1,649 | 1/27/2022 |
1.0.3 | 2,525 | 1/11/2022 |
1.0.2 | 34,454 | 1/2/2022 |
1.0.1 | 905 | 1/1/2022 |
1.0.0 | 1,013 | 12/29/2021 |
Update dependencies.