Skip to content

Commit

Permalink
Update interaction messages and flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nihlus committed Mar 6, 2021
1 parent 87d7a2d commit 8ef8bcc
Show file tree
Hide file tree
Showing 22 changed files with 315 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface IInteractionApplicationCommandCallbackData
/// <summary>
/// Gets the content of the message.
/// </summary>
string Content { get; }
Optional<string> Content { get; }

/// <summary>
/// Gets the embeds of the message.
Expand All @@ -51,5 +51,10 @@ public interface IInteractionApplicationCommandCallbackData
/// Gets the allowed mentions in the message.
/// </summary>
Optional<IAllowedMentions> AllowedMentions { get; }

/// <summary>
/// Gets the callback flags.
/// </summary>
Optional<InteractionCallbackFlags> Flags { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// IMessageInteraction.cs
//
// Author:
// Jarl Gullberg <jarl.gullberg@gmail.com>
//
// Copyright (c) 2017 Jarl Gullberg
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

using Remora.Discord.Core;

namespace Remora.Discord.API.Abstractions.Objects
{
/// <summary>
/// Represents additional data sent on a message that is a response to an interaction.
/// </summary>
public interface IMessageInteraction
{
/// <summary>
/// Gets the ID of the interaction.
/// </summary>
Snowflake ID { get; }

/// <summary>
/// Gets the interaction type.
/// </summary>
InteractionType Type { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// InteractionCallbackFlags.cs
//
// Author:
// Jarl Gullberg <jarl.gullberg@gmail.com>
//
// Copyright (c) 2017 Jarl Gullberg
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

using System;

namespace Remora.Discord.API.Abstractions.Objects
{
/// <summary>
/// Enumerates various callback flags.
/// </summary>
[Flags]
public enum InteractionCallbackFlags
{
/// <summary>
/// The callback message will only be visible to the executing user.
/// </summary>
Ephemeral = 1 << 7
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ public enum InteractionResponseType
/// </summary>
Pong = 1,

/// <summary>
/// Acknowledge a command without sending a message in return.
/// </summary>
Acknowledge = 2,

/// <summary>
/// Respond with a message, consuming the user input.
/// </summary>
ChannelMessage = 3,

/// <summary>
/// Respond with a message, showing the user input.
/// </summary>
Expand All @@ -53,6 +43,6 @@ public enum InteractionResponseType
/// <summary>
/// Acknowledge a command without sending a message, showing the user input.
/// </summary>
AcknowledgeWithSource = 5
DeferredChannelMessageWithSource = 5
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,10 @@ public interface IMessage
/// Gets the referenced message, if any. A null value in this context refers to a deleted message.
/// </summary>
Optional<IMessage?> ReferencedMessage { get; }

/// <summary>
/// Gets the interaction associated with this message, if any.
/// </summary>
Optional<IMessageInteraction> Interaction { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,20 @@ public interface IPartialMessage
/// Gets a set of bitwise flags describing extra features of the message.
/// </summary>
Optional<MessageFlags> Flags { get; }

/// <summary>
/// Gets the stickers sent with the message.
/// </summary>
Optional<IReadOnlyList<IMessageSticker>> Stickers { get; }

/// <summary>
/// Gets the referenced message, if any. A null value in this context refers to a deleted message.
/// </summary>
Optional<IMessage?> ReferencedMessage { get; }

/// <summary>
/// Gets the interaction associated with this message, if any.
/// </summary>
Optional<IMessageInteraction> Interaction { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<PropertyGroup>
<Version>9.0.1</Version>
<Version>10.0.0</Version>
<Description>
$(BaseDescription)

Expand All @@ -14,7 +14,7 @@
API.
</Description>
<PackageReleaseNotes>
Update dependencies.
Update slash command API, removing deprecated types.
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,68 +32,64 @@ namespace Remora.Discord.API.Gateway.Events
{
/// <inheritdoc cref="IMessageCreate"/>
[PublicAPI]
public record MessageCreate : Message, IMessageCreate
{
/// <inheritdoc cref="Message"/>
public MessageCreate
(
Snowflake id,
Snowflake channelID,
Optional<Snowflake> guildID,
IUser author,
Optional<IPartialGuildMember> member,
string content,
DateTimeOffset timestamp,
DateTimeOffset? editedTimestamp,
bool isTTS,
bool mentionsEveryone,
IReadOnlyList<IUserMention> mentions,
IReadOnlyList<Snowflake> mentionedRoles,
Optional<IReadOnlyList<IChannelMention>> mentionedChannels,
IReadOnlyList<IAttachment> attachments,
IReadOnlyList<IEmbed> embeds,
Optional<IReadOnlyList<IReaction>> reactions,
Optional<string> nonce,
bool isPinned,
Optional<Snowflake> webhookID,
MessageType type,
Optional<IMessageActivity> activity = default,
Optional<IMessageApplication> application = default,
Optional<IMessageReference> messageReference = default,
Optional<MessageFlags> flags = default,
Optional<IReadOnlyList<IMessageSticker>> stickers = default,
Optional<IMessage?> referencedMessage = default
)
: base
(
id,
channelID,
guildID,
author,
member,
content,
timestamp,
editedTimestamp,
isTTS,
mentionsEveryone,
mentions,
mentionedRoles,
mentionedChannels,
attachments,
embeds,
reactions,
nonce,
isPinned,
webhookID,
type,
activity,
application,
messageReference,
flags,
stickers,
referencedMessage
)
{
}
}
public record MessageCreate
(
Snowflake ID,
Snowflake ChannelID,
Optional<Snowflake> GuildID,
IUser Author,
Optional<IPartialGuildMember> Member,
string Content,
DateTimeOffset Timestamp,
DateTimeOffset? EditedTimestamp,
bool IsTTS,
bool MentionsEveryone,
IReadOnlyList<IUserMention> Mentions,
IReadOnlyList<Snowflake> MentionedRoles,
Optional<IReadOnlyList<IChannelMention>> MentionedChannels,
IReadOnlyList<IAttachment> Attachments,
IReadOnlyList<IEmbed> Embeds,
Optional<IReadOnlyList<IReaction>> Reactions,
Optional<string> Nonce,
bool IsPinned,
Optional<Snowflake> WebhookID,
MessageType Type,
Optional<IMessageActivity> Activity = default,
Optional<IMessageApplication> Application = default,
Optional<IMessageReference> MessageReference = default,
Optional<MessageFlags> Flags = default,
Optional<IReadOnlyList<IMessageSticker>> Stickers = default,
Optional<IMessage?> ReferencedMessage = default,
Optional<IMessageInteraction> Interaction = default
)
: Message
(
ID,
ChannelID,
GuildID,
Author,
Member,
Content,
Timestamp,
EditedTimestamp,
IsTTS,
MentionsEveryone,
Mentions,
MentionedRoles,
MentionedChannels,
Attachments,
Embeds,
Reactions,
Nonce,
IsPinned,
WebhookID,
Type,
Activity,
Application,
MessageReference,
Flags,
Stickers,
ReferencedMessage,
Interaction
), IMessageCreate;
}
Loading

0 comments on commit 8ef8bcc

Please sign in to comment.