Redesign embeds (#123)

TODO before merging:

- [x] /about
- [x] /ban
- [x] /unban
- [x] /kick
- [x] /mute
- [x] /unmute
- [x] /remind
- [x] /listremind
- [x] MessageEditedResponder
- [x] MessageDeletedResponder

---------

Signed-off-by: Macintosh II <mctaylxrs@outlook.com>
This commit is contained in:
Macintxsh 2023-09-29 18:36:16 +03:00 committed by GitHub
parent d5c4340210
commit 04897cab20
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 1054 additions and 1010 deletions

View file

@ -47,9 +47,7 @@
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root" xmlns="">
id="root"
xmlns="">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
@ -102,14 +100,10 @@
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 </value>
PublicKeyToken=b77a5c561934e089
</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 </value>
PublicKeyToken=b77a5c561934e089
</value>
</resheader> </resheader>
<data name="Ready" xml:space="preserve"> <data name="Ready" xml:space="preserve">
<value>I'm ready!</value> <value>I'm ready!</value>
@ -461,9 +455,6 @@
</data> </data>
<data name="MissingReminderText" xml:space="preserve"> <data name="MissingReminderText" xml:space="preserve">
<value>You need to specify reminder text!</value> <value>You need to specify reminder text!</value>
</data>
<data name="DescriptionReminderCreated" xml:space="preserve">
<value>OK, I'll mention you on {0}</value>
</data> </data>
<data name="InvalidRemindIn" xml:space="preserve"> <data name="InvalidRemindIn" xml:space="preserve">
<value>You need to specify when I should send you the reminder!</value> <value>You need to specify when I should send you the reminder!</value>
@ -528,14 +519,14 @@
<data name="AboutTitleDevelopers" xml:space="preserve"> <data name="AboutTitleDevelopers" xml:space="preserve">
<value>Developers:</value> <value>Developers:</value>
</data> </data>
<data name="AboutTitleWiki" xml:space="preserve"> <data name="AboutTitleRepository" xml:space="preserve">
<value>Boyfriend's Wiki Page:</value> <value>Boyfriend's source code</value>
</data> </data>
<data name="AboutBot" xml:space="preserve"> <data name="AboutBot" xml:space="preserve">
<value>About Boyfriend</value> <value>About Boyfriend</value>
</data> </data>
<data name="AboutDeveloper@mctaylors" xml:space="preserve"> <data name="AboutDeveloper@mctaylors" xml:space="preserve">
<value>logo and embed designer, Boyfriend's Wiki creator</value> <value>developer &amp; designer, Boyfriend's Wiki creator</value>
</data> </data>
<data name="AboutDeveloper@Octol1ttle" xml:space="preserve"> <data name="AboutDeveloper@Octol1ttle" xml:space="preserve">
<value>main developer</value> <value>main developer</value>
@ -600,6 +591,21 @@
<data name="AllSettingsReset" xml:space="preserve"> <data name="AllSettingsReset" xml:space="preserve">
<value>All settings have been reset</value> <value>All settings have been reset</value>
</data> </data>
<data name="DescriptionActionJumpToMessage" xml:space="preserve">
<value>Jump to message: {0}</value>
</data>
<data name="DescriptionActionJumpToChannel" xml:space="preserve">
<value>Jump to channel: {0}</value>
</data>
<data name="ReminderIndex" xml:space="preserve">
<value>Index: {0}</value>
</data>
<data name="ReminderWillBeSentOn" xml:space="preserve">
<value>The reminder will be sent on: {0}</value>
</data>
<data name="ReminderText" xml:space="preserve">
<value>Reminder text: {0}</value>
</data>
<data name="ShowInfoDisplayName" xml:space="preserve"> <data name="ShowInfoDisplayName" xml:space="preserve">
<value>Display name</value> <value>Display name</value>
</data> </data>

View file

@ -47,9 +47,7 @@
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root" xmlns="">
id="root"
xmlns="">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
@ -102,14 +100,10 @@
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 </value>
PublicKeyToken=b77a5c561934e089
</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 </value>
PublicKeyToken=b77a5c561934e089
</value>
</resheader> </resheader>
<data name="Ready" xml:space="preserve"> <data name="Ready" xml:space="preserve">
<value>Я запустился!</value> <value>Я запустился!</value>
@ -458,9 +452,6 @@
</data> </data>
<data name="MissingReminderText" xml:space="preserve"> <data name="MissingReminderText" xml:space="preserve">
<value>Тебе нужно указать текст напоминания!</value> <value>Тебе нужно указать текст напоминания!</value>
</data>
<data name="DescriptionReminderCreated" xml:space="preserve">
<value>Хорошо, я упомяну тебя {0}</value>
</data> </data>
<data name="InvalidRemindIn" xml:space="preserve"> <data name="InvalidRemindIn" xml:space="preserve">
<value>Нужно указать время, через которое придёт напоминание!</value> <value>Нужно указать время, через которое придёт напоминание!</value>
@ -528,20 +519,20 @@
<data name="AboutTitleDevelopers" xml:space="preserve"> <data name="AboutTitleDevelopers" xml:space="preserve">
<value>Разработчики:</value> <value>Разработчики:</value>
</data> </data>
<data name="AboutTitleWiki" xml:space="preserve"> <data name="AboutTitleRepository" xml:space="preserve">
<value>Страница Boyfriend's Wiki:</value> <value>Исходный код Boyfriend</value>
</data> </data>
<data name="AboutBot" xml:space="preserve"> <data name="AboutBot" xml:space="preserve">
<value>О Boyfriend</value> <value>О Boyfriend</value>
</data> </data>
<data name="AboutDeveloper@neroduckale" xml:space="preserve"> <data name="AboutDeveloper@neroduckale" xml:space="preserve">
<value>разрабочик</value> <value>разработчик</value>
</data> </data>
<data name="AboutDeveloper@Octol1ttle" xml:space="preserve"> <data name="AboutDeveloper@Octol1ttle" xml:space="preserve">
<value>основной разработчик</value> <value>основной разработчик</value>
</data> </data>
<data name="AboutDeveloper@mctaylors" xml:space="preserve"> <data name="AboutDeveloper@mctaylors" xml:space="preserve">
<value>дизайнер лого и эмбедов, создатель Boyfriend's Wiki</value> <value>разработчик и дизайнер, создатель Boyfriend's Wiki</value>
</data> </data>
<data name="ReminderCreated" xml:space="preserve"> <data name="ReminderCreated" xml:space="preserve">
<value>Напоминание для {0} создано</value> <value>Напоминание для {0} создано</value>
@ -600,6 +591,21 @@
<data name="AllSettingsReset" xml:space="preserve"> <data name="AllSettingsReset" xml:space="preserve">
<value>Все настройки были сброшены</value> <value>Все настройки были сброшены</value>
</data> </data>
<data name="DescriptionActionJumpToMessage" xml:space="preserve">
<value>Перейти к сообщению: {0}</value>
</data>
<data name="DescriptionActionJumpToChannel" xml:space="preserve">
<value>Перейти к каналу: {0}</value>
</data>
<data name="ReminderIndex" xml:space="preserve">
<value>Индекс: {0}</value>
</data>
<data name="ReminderWillBeSentOn" xml:space="preserve">
<value>Напоминание будет отправлено: {0}</value>
</data>
<data name="ReminderText" xml:space="preserve">
<value>Текст напоминалки: {0}</value>
</data>
<data name="ShowInfoDisplayName" xml:space="preserve"> <data name="ShowInfoDisplayName" xml:space="preserve">
<value>Отображаемое имя</value> <value>Отображаемое имя</value>
</data> </data>

View file

@ -47,9 +47,7 @@
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root" xmlns="">
id="root"
xmlns="">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
@ -102,14 +100,10 @@
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 </value>
PublicKeyToken=b77a5c561934e089
</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 </value>
PublicKeyToken=b77a5c561934e089
</value>
</resheader> </resheader>
<data name="Ready" xml:space="preserve"> <data name="Ready" xml:space="preserve">
<value>я родился!</value> <value>я родился!</value>
@ -461,9 +455,6 @@
</data> </data>
<data name="MissingReminderText" xml:space="preserve"> <data name="MissingReminderText" xml:space="preserve">
<value>для крафта напоминалки нужен текст</value> <value>для крафта напоминалки нужен текст</value>
</data>
<data name="DescriptionReminderCreated" xml:space="preserve">
<value>вас понял, упоминание будет {0}</value>
</data> </data>
<data name="InvalidRemindIn" xml:space="preserve"> <data name="InvalidRemindIn" xml:space="preserve">
<value>шизоид у меня на часах такого нету</value> <value>шизоид у меня на часах такого нету</value>
@ -528,14 +519,14 @@
<data name="AboutTitleDevelopers" xml:space="preserve"> <data name="AboutTitleDevelopers" xml:space="preserve">
<value>девелоперы:</value> <value>девелоперы:</value>
</data> </data>
<data name="AboutTitleWiki" xml:space="preserve"> <data name="AboutTitleRepository" xml:space="preserve">
<value>страничка Boyfriend's Wiki:</value> <value>репа Boyfriend (тык)</value>
</data> </data>
<data name="AboutBot" xml:space="preserve"> <data name="AboutBot" xml:space="preserve">
<value>немного о Boyfriend</value> <value>немного о Boyfriend</value>
</data> </data>
<data name="AboutDeveloper@mctaylors" xml:space="preserve"> <data name="AboutDeveloper@mctaylors" xml:space="preserve">
<value>скучный лого/эмбед дизайнер создавший Boyfriend's Wiki</value> <value>скучный девелопер + дизайнер создавший Boyfriend's Wiki</value>
</data> </data>
<data name="AboutDeveloper@neroduckale" xml:space="preserve"> <data name="AboutDeveloper@neroduckale" xml:space="preserve">
<value>ВАЖНЫЙ соучастник кодинг-стримов @Octol1ttle</value> <value>ВАЖНЫЙ соучастник кодинг-стримов @Octol1ttle</value>
@ -600,6 +591,21 @@
<data name="AllSettingsReset" xml:space="preserve"> <data name="AllSettingsReset" xml:space="preserve">
<value>откатываемся к заводским...</value> <value>откатываемся к заводским...</value>
</data> </data>
<data name="DescriptionActionJumpToMessage" xml:space="preserve">
<value>чекнуть сообщение: {0}</value>
</data>
<data name="DescriptionActionJumpToChannel" xml:space="preserve">
<value>чекнуть канал: {0}</value>
</data>
<data name="ReminderIndex" xml:space="preserve">
<value>индекс: {0}</value>
</data>
<data name="ReminderWillBeSentOn" xml:space="preserve">
<value>я пну тебе это: {0}</value>
</data>
<data name="ReminderText" xml:space="preserve">
<value>че там в напоминалке: {0}</value>
</data>
<data name="ShowInfoDisplayName" xml:space="preserve"> <data name="ShowInfoDisplayName" xml:space="preserve">
<value>дисплейнейм</value> <value>дисплейнейм</value>
</data> </data>

View file

@ -12,7 +12,7 @@ using Remora.Discord.Commands.Conditions;
using Remora.Discord.Commands.Contexts; using Remora.Discord.Commands.Contexts;
using Remora.Discord.Commands.Feedback.Services; using Remora.Discord.Commands.Feedback.Services;
using Remora.Discord.Extensions.Embeds; using Remora.Discord.Extensions.Embeds;
using Remora.Discord.Extensions.Formatting; using Remora.Rest.Core;
using Remora.Results; using Remora.Results;
namespace Boyfriend.Commands; namespace Boyfriend.Commands;
@ -23,20 +23,29 @@ namespace Boyfriend.Commands;
[UsedImplicitly] [UsedImplicitly]
public class AboutCommandGroup : CommandGroup public class AboutCommandGroup : CommandGroup
{ {
private static readonly string[] Developers = { "Octol1ttle", "mctaylors", "neroduckale" }; private static readonly (string Username, Snowflake Id)[] Developers =
{
("Octol1ttle", new Snowflake(504343489664909322)),
("mctaylors", new Snowflake(326642240229474304)),
("neroduckale", new Snowflake(474943797063843851))
};
private readonly ICommandContext _context; private readonly ICommandContext _context;
private readonly FeedbackService _feedback; private readonly FeedbackService _feedback;
private readonly GuildDataService _guildData; private readonly GuildDataService _guildData;
private readonly IDiscordRestUserAPI _userApi; private readonly IDiscordRestUserAPI _userApi;
private readonly IDiscordRestGuildAPI _guildApi;
public AboutCommandGroup( public AboutCommandGroup(
ICommandContext context, GuildDataService guildData, ICommandContext context, GuildDataService guildData,
FeedbackService feedback, IDiscordRestUserAPI userApi) FeedbackService feedback, IDiscordRestUserAPI userApi,
IDiscordRestGuildAPI guildApi)
{ {
_context = context; _context = context;
_guildData = guildData; _guildData = guildData;
_feedback = feedback; _feedback = feedback;
_userApi = userApi; _userApi = userApi;
_guildApi = guildApi;
} }
/// <summary> /// <summary>
@ -66,20 +75,22 @@ public class AboutCommandGroup : CommandGroup
var cfg = await _guildData.GetSettings(guildId, CancellationToken); var cfg = await _guildData.GetSettings(guildId, CancellationToken);
Messages.Culture = GuildSettings.Language.Get(cfg); Messages.Culture = GuildSettings.Language.Get(cfg);
return await SendAboutBotAsync(currentUser, CancellationToken); return await SendAboutBotAsync(currentUser, guildId, CancellationToken);
} }
private async Task<Result> SendAboutBotAsync(IUser currentUser, CancellationToken ct = default) private async Task<Result> SendAboutBotAsync(IUser currentUser, Snowflake guildId, CancellationToken ct = default)
{ {
var builder = new StringBuilder().AppendLine(Markdown.Bold(Messages.AboutTitleDevelopers)); var builder = new StringBuilder().Append("### ").AppendLine(Messages.AboutTitleDevelopers);
foreach (var dev in Developers) foreach (var dev in Developers)
{ {
builder.AppendLine($"@{dev} — {$"AboutDeveloper@{dev}".Localized()}"); var guildMemberResult = await _guildApi.GetGuildMemberAsync(
guildId, dev.Id, ct);
var tag = guildMemberResult.IsSuccess ? $"<@{dev.Id}>" : $"@{dev.Username}";
builder.AppendLine($"- {tag} — {$"AboutDeveloper@{dev.Username}".Localized()}");
} }
builder.AppendLine() builder.Append($"### [{Messages.AboutTitleRepository}](https://github.com/LabsDevelopment/Boyfriend)");
.AppendLine(Markdown.Bold(Messages.AboutTitleWiki))
.AppendLine("https://github.com/LabsDevelopment/Boyfriend/wiki");
var embed = new EmbedBuilder().WithSmallTitle(Messages.AboutBot, currentUser) var embed = new EmbedBuilder().WithSmallTitle(Messages.AboutBot, currentUser)
.WithDescription(builder.ToString()) .WithDescription(builder.ToString())

View file

@ -133,10 +133,11 @@ public class BanCommandGroup : CommandGroup
return await _feedback.SendContextualEmbedResultAsync(errorEmbed, ct); return await _feedback.SendContextualEmbedResultAsync(errorEmbed, ct);
} }
var builder = new StringBuilder().AppendLine(string.Format(Messages.DescriptionActionReason, reason)); var builder = new StringBuilder().Append("- ")
.AppendLine(string.Format(Messages.DescriptionActionReason, reason));
if (duration is not null) if (duration is not null)
{ {
builder.Append( builder.Append("- ").Append(
string.Format( string.Format(
Messages.DescriptionActionExpiresAt, Messages.DescriptionActionExpiresAt,
Markdown.Timestamp(DateTimeOffset.UtcNow.Add(duration.Value)))); Markdown.Timestamp(DateTimeOffset.UtcNow.Add(duration.Value))));
@ -271,9 +272,10 @@ public class BanCommandGroup : CommandGroup
.WithColour(ColorsList.Green).Build(); .WithColour(ColorsList.Green).Build();
var title = string.Format(Messages.UserUnbanned, target.GetTag()); var title = string.Format(Messages.UserUnbanned, target.GetTag());
var description = string.Format(Messages.DescriptionActionReason, reason); var description = new StringBuilder().Append("- ")
.Append(string.Format(Messages.DescriptionActionReason, reason));
var logResult = _utility.LogActionAsync( var logResult = _utility.LogActionAsync(
data.Settings, channelId, user, title, description, target, ColorsList.Green, ct: ct); data.Settings, channelId, user, title, description.ToString(), target, ColorsList.Green, ct: ct);
if (!logResult.IsSuccess) if (!logResult.IsSuccess)
{ {
return Result.FromError(logResult.Error); return Result.FromError(logResult.Error);

View file

@ -131,7 +131,7 @@ public class KickCommandGroup : CommandGroup
{ {
var dmEmbed = new EmbedBuilder().WithGuildTitle(guild) var dmEmbed = new EmbedBuilder().WithGuildTitle(guild)
.WithTitle(Messages.YouWereKicked) .WithTitle(Messages.YouWereKicked)
.WithDescription(string.Format(Messages.DescriptionActionReason, reason)) .WithDescription($"- {string.Format(Messages.DescriptionActionReason, reason)}")
.WithActionFooter(user) .WithActionFooter(user)
.WithCurrentTimestamp() .WithCurrentTimestamp()
.WithColour(ColorsList.Red) .WithColour(ColorsList.Red)
@ -156,7 +156,7 @@ public class KickCommandGroup : CommandGroup
data.GetOrCreateMemberData(target.ID).Roles.Clear(); data.GetOrCreateMemberData(target.ID).Roles.Clear();
var title = string.Format(Messages.UserKicked, target.GetTag()); var title = string.Format(Messages.UserKicked, target.GetTag());
var description = string.Format(Messages.DescriptionActionReason, reason); var description = $"- {string.Format(Messages.DescriptionActionReason, reason)}";
var logResult = _utility.LogActionAsync( var logResult = _utility.LogActionAsync(
data.Settings, channelId, user, title, description, target, ColorsList.Red, ct: ct); data.Settings, channelId, user, title, description, target, ColorsList.Red, ct: ct);
if (!logResult.IsSuccess) if (!logResult.IsSuccess)

View file

@ -152,9 +152,8 @@ public class MuteCommandGroup : CommandGroup
} }
var title = string.Format(Messages.UserMuted, target.GetTag()); var title = string.Format(Messages.UserMuted, target.GetTag());
var description = new StringBuilder().AppendLine(string.Format(Messages.DescriptionActionReason, reason)) var description = new StringBuilder().Append("- ").AppendLine(string.Format(Messages.DescriptionActionReason, reason))
.Append( .Append("- ").Append(string.Format(
string.Format(
Messages.DescriptionActionExpiresAt, Markdown.Timestamp(until))).ToString(); Messages.DescriptionActionExpiresAt, Markdown.Timestamp(until))).ToString();
var logResult = _utility.LogActionAsync( var logResult = _utility.LogActionAsync(
@ -211,9 +210,8 @@ public class MuteCommandGroup : CommandGroup
} }
var title = string.Format(Messages.UserMuted, target.GetTag()); var title = string.Format(Messages.UserMuted, target.GetTag());
var description = new StringBuilder().AppendLine(string.Format(Messages.DescriptionActionReason, reason)) var description = new StringBuilder().Append("- ").AppendLine(string.Format(Messages.DescriptionActionReason, reason))
.Append( .Append("- ").Append(string.Format(
string.Format(
Messages.DescriptionActionExpiresAt, Markdown.Timestamp(until))).ToString(); Messages.DescriptionActionExpiresAt, Markdown.Timestamp(until))).ToString();
var logResult = _utility.LogActionAsync( var logResult = _utility.LogActionAsync(
@ -328,7 +326,7 @@ public class MuteCommandGroup : CommandGroup
} }
var title = string.Format(Messages.UserUnmuted, target.GetTag()); var title = string.Format(Messages.UserUnmuted, target.GetTag());
var description = string.Format(Messages.DescriptionActionReason, reason); var description = $"- {string.Format(Messages.DescriptionActionReason, reason)}";
var logResult = _utility.LogActionAsync( var logResult = _utility.LogActionAsync(
data.Settings, channelId, user, title, description, target, ColorsList.Green, ct: ct); data.Settings, channelId, user, title, description, target, ColorsList.Green, ct: ct);
if (!logResult.IsSuccess) if (!logResult.IsSuccess)
@ -372,7 +370,7 @@ public class MuteCommandGroup : CommandGroup
} }
var title = string.Format(Messages.UserUnmuted, target.GetTag()); var title = string.Format(Messages.UserUnmuted, target.GetTag());
var description = string.Format(Messages.DescriptionActionReason, reason); var description = $"- {string.Format(Messages.DescriptionActionReason, reason)}";
var logResult = _utility.LogActionAsync( var logResult = _utility.LogActionAsync(
data.Settings, channelId, user, title, description, target, ColorsList.Green, ct: ct); data.Settings, channelId, user, title, description, target, ColorsList.Green, ct: ct);
if (!logResult.IsSuccess) if (!logResult.IsSuccess)

View file

@ -19,7 +19,7 @@ using Remora.Results;
namespace Boyfriend.Commands; namespace Boyfriend.Commands;
/// <summary> /// <summary>
/// Handles the command to manage reminders: /remind /// Handles commands to manage reminders: /remind, /listremind, /delremind
/// </summary> /// </summary>
[UsedImplicitly] [UsedImplicitly]
public class RemindCommandGroup : CommandGroup public class RemindCommandGroup : CommandGroup
@ -88,8 +88,9 @@ public class RemindCommandGroup : CommandGroup
for (var i = data.Reminders.Count - 1; i >= 0; i--) for (var i = data.Reminders.Count - 1; i >= 0; i--)
{ {
var reminder = data.Reminders[i]; var reminder = data.Reminders[i];
builder.AppendLine( builder.Append("- ").AppendLine(string.Format(Messages.ReminderIndex, Markdown.InlineCode(i.ToString())))
$"- {Markdown.InlineCode(i.ToString())} - {Markdown.InlineCode(reminder.Text)} - {Markdown.Timestamp(reminder.At)}"); .Append(" - ").AppendLine(string.Format(Messages.ReminderText, Markdown.InlineCode(reminder.Text)))
.Append(" - ").AppendLine(string.Format(Messages.ReminderWillBeSentOn, Markdown.Timestamp(reminder.At)));
} }
var embed = new EmbedBuilder().WithSmallTitle( var embed = new EmbedBuilder().WithSmallTitle(
@ -149,8 +150,13 @@ public class RemindCommandGroup : CommandGroup
Text = message Text = message
}); });
var embed = new EmbedBuilder().WithSmallTitle(string.Format(Messages.ReminderCreated, user.GetTag()), user) var builder = new StringBuilder().Append("- ").AppendLine(string.Format(
.WithDescription(string.Format(Messages.DescriptionReminderCreated, Markdown.Timestamp(remindAt))) Messages.ReminderText, Markdown.InlineCode(message)))
.Append("- ").Append(string.Format(Messages.ReminderWillBeSentOn, Markdown.Timestamp(remindAt)));
var embed = new EmbedBuilder().WithSmallTitle(
string.Format(Messages.ReminderCreated, user.GetTag()), user)
.WithDescription(builder.ToString())
.WithColour(ColorsList.Green) .WithColour(ColorsList.Green)
.Build(); .Build();

View file

@ -17,22 +17,6 @@ namespace Boyfriend;
public static class Extensions public static class Extensions
{ {
/// <summary>
/// Adds a footer with the <paramref name="user" />'s avatar and tag (@username or username#0000).
/// </summary>
/// <param name="builder">The builder to add the footer to.</param>
/// <param name="user">The user whose tag and avatar to add.</param>
/// <returns>The builder with the added footer.</returns>
public static EmbedBuilder WithUserFooter(this EmbedBuilder builder, IUser user)
{
var avatarUrlResult = CDN.GetUserAvatarUrl(user, imageSize: 256);
var avatarUrl = avatarUrlResult.IsSuccess
? avatarUrlResult.Entity.AbsoluteUri
: CDN.GetDefaultUserAvatarUrl(user, imageSize: 256).Entity.AbsoluteUri;
return builder.WithFooter(new EmbedFooter(user.GetTag(), avatarUrl));
}
/// <summary> /// <summary>
/// Adds a footer representing that an action was performed by a <paramref name="user" />. /// Adds a footer representing that an action was performed by a <paramref name="user" />.
/// </summary> /// </summary>

View file

@ -744,12 +744,6 @@ namespace Boyfriend {
} }
} }
internal static string DescriptionReminderCreated {
get {
return ResourceManager.GetString("DescriptionReminderCreated", resourceCulture);
}
}
internal static string InvalidRemindIn { internal static string InvalidRemindIn {
get { get {
return ResourceManager.GetString("InvalidRemindIn", resourceCulture); return ResourceManager.GetString("InvalidRemindIn", resourceCulture);
@ -876,9 +870,9 @@ namespace Boyfriend {
} }
} }
internal static string AboutTitleWiki { internal static string AboutTitleRepository {
get { get {
return ResourceManager.GetString("AboutTitleWiki", resourceCulture); return ResourceManager.GetString("AboutTitleRepository", resourceCulture);
} }
} }
@ -1014,6 +1008,36 @@ namespace Boyfriend {
} }
} }
internal static string DescriptionActionJumpToMessage {
get {
return ResourceManager.GetString("DescriptionActionJumpToMessage", resourceCulture);
}
}
internal static string DescriptionActionJumpToChannel {
get {
return ResourceManager.GetString("DescriptionActionJumpToChannel", resourceCulture);
}
}
internal static string ReminderIndex {
get {
return ResourceManager.GetString("ReminderIndex", resourceCulture);
}
}
internal static string ReminderWillBeSentOn {
get {
return ResourceManager.GetString("ReminderWillBeSentOn", resourceCulture);
}
}
internal static string ReminderText {
get {
return ResourceManager.GetString("ReminderText", resourceCulture);
}
}
internal static string ShowInfoTitle { internal static string ShowInfoTitle {
get { get {
return ResourceManager.GetString("ShowInfoTitle", resourceCulture); return ResourceManager.GetString("ShowInfoTitle", resourceCulture);

View file

@ -1,3 +1,4 @@
using System.Text;
using Boyfriend.Data; using Boyfriend.Data;
using Boyfriend.Services; using Boyfriend.Services;
using JetBrains.Annotations; using JetBrains.Annotations;
@ -81,13 +82,17 @@ public class MessageDeletedResponder : IResponder<IMessageDelete>
Messages.Culture = GuildSettings.Language.Get(cfg); Messages.Culture = GuildSettings.Language.Get(cfg);
var builder = new StringBuilder().AppendLine(
string.Format(Messages.DescriptionActionJumpToChannel,
Mention.Channel(gatewayEvent.ChannelID)))
.AppendLine(message.Content.InBlockCode());
var embed = new EmbedBuilder() var embed = new EmbedBuilder()
.WithSmallTitle( .WithSmallTitle(
string.Format( string.Format(
Messages.CachedMessageDeleted, Messages.CachedMessageDeleted,
message.Author.GetTag()), message.Author) message.Author.GetTag()), message.Author)
.WithDescription( .WithDescription(builder.ToString())
$"{Mention.Channel(gatewayEvent.ChannelID)}\n{message.Content.InBlockCode()}")
.WithActionFooter(user) .WithActionFooter(user)
.WithTimestamp(message.Timestamp) .WithTimestamp(message.Timestamp)
.WithColour(ColorsList.Red) .WithColour(ColorsList.Red)

View file

@ -1,3 +1,4 @@
using System.Text;
using Boyfriend.Data; using Boyfriend.Data;
using Boyfriend.Services; using Boyfriend.Services;
using DiffPlex.DiffBuilder; using DiffPlex.DiffBuilder;
@ -23,16 +24,13 @@ public class MessageEditedResponder : IResponder<IMessageUpdate>
private readonly CacheService _cacheService; private readonly CacheService _cacheService;
private readonly IDiscordRestChannelAPI _channelApi; private readonly IDiscordRestChannelAPI _channelApi;
private readonly GuildDataService _guildData; private readonly GuildDataService _guildData;
private readonly IDiscordRestUserAPI _userApi;
public MessageEditedResponder( public MessageEditedResponder(
CacheService cacheService, IDiscordRestChannelAPI channelApi, GuildDataService guildData, CacheService cacheService, IDiscordRestChannelAPI channelApi, GuildDataService guildData)
IDiscordRestUserAPI userApi)
{ {
_cacheService = cacheService; _cacheService = cacheService;
_channelApi = channelApi; _channelApi = channelApi;
_guildData = guildData; _guildData = guildData;
_userApi = userApi;
} }
public async Task<Result> RespondAsync(IMessageUpdate gatewayEvent, CancellationToken ct = default) public async Task<Result> RespondAsync(IMessageUpdate gatewayEvent, CancellationToken ct = default)
@ -92,20 +90,18 @@ public class MessageEditedResponder : IResponder<IMessageUpdate>
// NOTE: Awaiting this might not even solve this if the same responder is called asynchronously // NOTE: Awaiting this might not even solve this if the same responder is called asynchronously
_ = _channelApi.GetChannelMessageAsync(channelId, messageId, ct); _ = _channelApi.GetChannelMessageAsync(channelId, messageId, ct);
var currentUserResult = await _userApi.GetCurrentUserAsync(ct);
if (!currentUserResult.IsDefined(out var currentUser))
{
return Result.FromError(currentUserResult);
}
var diff = InlineDiffBuilder.Diff(message.Content, newContent); var diff = InlineDiffBuilder.Diff(message.Content, newContent);
Messages.Culture = GuildSettings.Language.Get(cfg); Messages.Culture = GuildSettings.Language.Get(cfg);
var builder = new StringBuilder().AppendLine(
string.Format(Messages.DescriptionActionJumpToMessage,
$"https://discord.com/channels/{guildId}/{channelId}/{messageId}"))
.AppendLine(diff.AsMarkdown());
var embed = new EmbedBuilder() var embed = new EmbedBuilder()
.WithSmallTitle(string.Format(Messages.CachedMessageEdited, message.Author.GetTag()), message.Author) .WithSmallTitle(string.Format(Messages.CachedMessageEdited, message.Author.GetTag()), message.Author)
.WithDescription($"https://discord.com/channels/{guildId}/{channelId}/{messageId}\n{diff.AsMarkdown()}") .WithDescription(builder.ToString())
.WithUserFooter(currentUser)
.WithTimestamp(timestamp.Value) .WithTimestamp(timestamp.Value)
.WithColour(ColorsList.Yellow) .WithColour(ColorsList.Yellow)
.Build(); .Build();