mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat(bot): initial support for Discord application commands
This commit is contained in:
parent
c69ab99519
commit
86717603d3
21 changed files with 452 additions and 18 deletions
|
|
@ -90,6 +90,11 @@ public class DiscordApiClient
|
|||
_client.Delete($"/channels/{channelId}/messages/{messageId}/reactions/{EncodeEmoji(emoji)}",
|
||||
("DeleteAllReactionsForEmoji", channelId));
|
||||
|
||||
public Task<ApplicationCommand[]?> ReplaceGlobalApplicationCommands(ulong applicationId,
|
||||
List<ApplicationCommandRequest> requests) =>
|
||||
_client.Put<ApplicationCommand[]>($"/applications/{applicationId}/commands",
|
||||
("ReplaceGlobalApplicationCommands", applicationId), requests);
|
||||
|
||||
public Task<ApplicationCommand> CreateGlobalApplicationCommand(ulong applicationId,
|
||||
ApplicationCommandRequest request) =>
|
||||
_client.Post<ApplicationCommand>($"/applications/{applicationId}/commands",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace Myriad.Rest.Types;
|
|||
|
||||
public record ApplicationCommandRequest
|
||||
{
|
||||
public ApplicationCommand.ApplicationCommandType Type { get; init; }
|
||||
public string Name { get; init; }
|
||||
public string Description { get; init; }
|
||||
public List<ApplicationCommandOption>? Options { get; init; }
|
||||
|
|
|
|||
|
|
@ -2,8 +2,16 @@ namespace Myriad.Types;
|
|||
|
||||
public record ApplicationCommand
|
||||
{
|
||||
public enum ApplicationCommandType
|
||||
{
|
||||
ChatInput = 1,
|
||||
User = 2,
|
||||
Message = 3,
|
||||
}
|
||||
|
||||
public ulong Id { get; init; }
|
||||
public ulong ApplicationId { get; init; }
|
||||
public ApplicationCommandType Type { get; init; }
|
||||
public string Name { get; init; }
|
||||
public string Description { get; init; }
|
||||
public ApplicationCommandOption[]? Options { get; init; }
|
||||
|
|
|
|||
|
|
@ -6,5 +6,14 @@ public record ApplicationCommandInteractionData
|
|||
public string? Name { get; init; }
|
||||
public ApplicationCommandInteractionDataOption[]? Options { get; init; }
|
||||
public string? CustomId { get; init; }
|
||||
public ulong? TargetId { get; init; }
|
||||
public ComponentType? ComponentType { get; init; }
|
||||
public InteractionResolvedData Resolved { get; init; }
|
||||
public MessageComponent[]? Components { get; init; }
|
||||
|
||||
public record InteractionResolvedData
|
||||
{
|
||||
public Dictionary<ulong, Message>? Messages { get; init; }
|
||||
public Dictionary<ulong, User>? Users { get; init; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue