-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"Translate To..." Context Menu Message Command (#211)
- Loading branch information
Showing
46 changed files
with
2,057 additions
and
937 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
src/DiscordTranslationBot/Discord/Events/MessageCommandExecutedEvent.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
src/DiscordTranslationBot/Discord/Events/SlashCommandExecutedEvent.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace DiscordTranslationBot.Discord.Models; | ||
|
||
public sealed class JumpUrl | ||
{ | ||
/// <summary> | ||
/// Indicates if this jump URL is for a direct-message channel. | ||
/// </summary> | ||
public required bool IsDmChannel { get; init; } | ||
|
||
/// <summary> | ||
/// Guild ID. Null if <see cref="IsDmChannel" /> is true. | ||
/// </summary> | ||
public required ulong? GuildId { get; init; } | ||
|
||
/// <summary> | ||
/// Channel ID. | ||
/// </summary> | ||
public required ulong ChannelId { get; init; } | ||
|
||
/// <summary> | ||
/// Message ID. | ||
/// </summary> | ||
public required ulong MessageId { get; init; } | ||
} |
22 changes: 22 additions & 0 deletions
22
src/DiscordTranslationBot/Mediator/ValidatedTaskWhenAllPublisher.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using DiscordTranslationBot.Extensions; | ||
|
||
namespace DiscordTranslationBot.Mediator; | ||
|
||
public sealed class ValidatedTaskWhenAllPublisher : INotificationPublisher | ||
{ | ||
private readonly TaskWhenAllPublisher _taskWhenAllPublisher = new(); | ||
|
||
public ValueTask Publish<TNotification>( | ||
NotificationHandlers<TNotification> handlers, | ||
TNotification notification, | ||
CancellationToken cancellationToken) | ||
where TNotification : INotification | ||
{ | ||
if (!notification.TryValidate(out var validationResults)) | ||
{ | ||
throw new MessageValidationException(notification.GetType().Name, validationResults); | ||
} | ||
|
||
return _taskWhenAllPublisher.Publish(handlers, notification, cancellationToken); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/DiscordTranslationBot/Notifications/Events/ButtonExecutedNotification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Discord; | ||
|
||
namespace DiscordTranslationBot.Notifications.Events; | ||
|
||
/// <summary> | ||
/// Notification for the Discord ButtonExecuted event. | ||
/// </summary> | ||
public sealed class ButtonExecutedNotification : INotification | ||
{ | ||
/// <summary> | ||
/// The button component interaction. | ||
/// </summary> | ||
[Required] | ||
public required IComponentInteraction Interaction { get; init; } | ||
} |
6 changes: 4 additions & 2 deletions
6
...ionBot/Discord/Events/JoinedGuildEvent.cs → ...cations/Events/JoinedGuildNotification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Discord; | ||
|
||
namespace DiscordTranslationBot.Discord.Events; | ||
namespace DiscordTranslationBot.Notifications.Events; | ||
|
||
/// <summary> | ||
/// Notification for the Discord joined guild event. | ||
/// </summary> | ||
public sealed class JoinedGuildEvent : INotification | ||
public sealed class JoinedGuildNotification : INotification | ||
{ | ||
/// <summary> | ||
/// The guild that the bot joined. | ||
/// </summary> | ||
[Required] | ||
public required IGuild Guild { get; init; } | ||
} |
16 changes: 16 additions & 0 deletions
16
src/DiscordTranslationBot/Notifications/Events/MessageCommandExecutedNotification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Discord; | ||
|
||
namespace DiscordTranslationBot.Notifications.Events; | ||
|
||
/// <summary> | ||
/// Notification for the Discord MessageCommandExecuted event. | ||
/// </summary> | ||
public sealed class MessageCommandExecutedNotification : INotification | ||
{ | ||
/// <summary> | ||
/// The message command interaction. | ||
/// </summary> | ||
[Required] | ||
public required IMessageCommandInteraction Interaction { get; init; } | ||
} |
8 changes: 6 additions & 2 deletions
8
...nBot/Discord/Events/ReactionAddedEvent.cs → ...tions/Events/ReactionAddedNotification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Discord; | ||
using DiscordTranslationBot.Discord.Models; | ||
|
||
namespace DiscordTranslationBot.Discord.Events; | ||
namespace DiscordTranslationBot.Notifications.Events; | ||
|
||
/// <summary> | ||
/// Notification for the Discord ReactionAdded event. | ||
/// </summary> | ||
public sealed class ReactionAddedEvent : INotification | ||
public sealed class ReactionAddedNotification : INotification | ||
{ | ||
/// <summary> | ||
/// The user message. | ||
/// </summary> | ||
[Required] | ||
public required IUserMessage Message { get; init; } | ||
|
||
/// <summary> | ||
/// The channel. | ||
/// </summary> | ||
[Required] | ||
public required IMessageChannel Channel { get; init; } | ||
|
||
/// <summary> | ||
/// The reaction. | ||
/// </summary> | ||
[Required] | ||
public required ReactionInfo ReactionInfo { get; init; } | ||
} |
6 changes: 6 additions & 0 deletions
6
src/DiscordTranslationBot/Notifications/Events/ReadyNotification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace DiscordTranslationBot.Notifications.Events; | ||
|
||
/// <summary> | ||
/// Notification for the Discord ready event. | ||
/// </summary> | ||
public sealed class ReadyNotification : INotification; |
16 changes: 16 additions & 0 deletions
16
src/DiscordTranslationBot/Notifications/Events/SelectMenuExecutedNotification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Discord; | ||
|
||
namespace DiscordTranslationBot.Notifications.Events; | ||
|
||
/// <summary> | ||
/// Notification for the Discord SelectMenuExecuted event. | ||
/// </summary> | ||
public sealed class SelectMenuExecutedNotification : INotification | ||
{ | ||
/// <summary> | ||
/// The select menu component interaction. | ||
/// </summary> | ||
[Required] | ||
public required IComponentInteraction Interaction { get; init; } | ||
} |
16 changes: 16 additions & 0 deletions
16
src/DiscordTranslationBot/Notifications/Events/SlashCommandExecutedNotification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Discord; | ||
|
||
namespace DiscordTranslationBot.Notifications.Events; | ||
|
||
/// <summary> | ||
/// Notification for the Discord SlashCommandExecuted event. | ||
/// </summary> | ||
public sealed class SlashCommandExecutedNotification : INotification | ||
{ | ||
/// <summary> | ||
/// The slash command interaction. | ||
/// </summary> | ||
[Required] | ||
public required ISlashCommandInteraction Interaction { get; init; } | ||
} |
Oops, something went wrong.