mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-20 00:43:36 +03:00
Redesign /ban, /unban, MessageEditedResponder
idk about MessageEditedResponder, maybe subject to change
This commit is contained in:
parent
7d0918a319
commit
111ba33433
6 changed files with 29 additions and 16 deletions
|
@ -600,4 +600,7 @@
|
||||||
<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>
|
||||||
</root>
|
</root>
|
||||||
|
|
|
@ -600,4 +600,7 @@
|
||||||
<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>
|
||||||
</root>
|
</root>
|
||||||
|
|
|
@ -600,4 +600,7 @@
|
||||||
<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>
|
||||||
</root>
|
</root>
|
||||||
|
|
|
@ -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);
|
||||||
|
|
6
src/Messages.Designer.cs
generated
6
src/Messages.Designer.cs
generated
|
@ -1013,5 +1013,11 @@ namespace Boyfriend {
|
||||||
return ResourceManager.GetString("AllSettingsReset", resourceCulture);
|
return ResourceManager.GetString("AllSettingsReset", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static string DescriptionActionJumpToMessage {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("DescriptionActionJumpToMessage", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
Loading…
Add table
Reference in a new issue