mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-29 10:39:53 +03:00
More minor fixes and changes
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
6bee9ac0fc
commit
3688c60318
6 changed files with 804 additions and 1197 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using Boyfriend.Services;
|
||||
using Boyfriend.Services.Data;
|
||||
using Remora.Commands.Attributes;
|
||||
|
@ -11,6 +12,7 @@ using Remora.Discord.Commands.Contexts;
|
|||
using Remora.Discord.Commands.Extensions;
|
||||
using Remora.Discord.Commands.Feedback.Services;
|
||||
using Remora.Discord.Extensions.Embeds;
|
||||
using Remora.Discord.Extensions.Formatting;
|
||||
using Remora.Results;
|
||||
|
||||
// ReSharper disable ClassNeverInstantiated.Global
|
||||
|
@ -63,7 +65,8 @@ public class BanCommandGroup : CommandGroup {
|
|||
[RequireBotDiscordPermissions(DiscordPermission.BanMembers)]
|
||||
[Description("банит пидора")]
|
||||
public async Task<Result> BanUserAsync(
|
||||
[Description("юзер кого банить")] IUser target, [Description("причина зачем банить")] string reason, TimeSpan? duration = null) {
|
||||
[Description("юзер кого банить")] IUser target, [Description("причина зачем банить")] string reason,
|
||||
TimeSpan? duration = null) {
|
||||
// Data checks
|
||||
if (!_context.TryGetGuildID(out var guildId))
|
||||
return Result.FromError(new ArgumentNullError(nameof(guildId)));
|
||||
|
@ -107,11 +110,12 @@ public class BanCommandGroup : CommandGroup {
|
|||
return Result.FromError(userResult);
|
||||
|
||||
var banResult = await _guildApi.CreateGuildBanAsync(
|
||||
guildId.Value, target.ID, reason: $"({user.GetTag()}) {reason.EncodeHeader()}",
|
||||
guildId.Value, target.ID, reason: $"({user.GetTag()}) {reason}".EncodeHeader(),
|
||||
ct: CancellationToken);
|
||||
if (!banResult.IsSuccess)
|
||||
return Result.FromError(banResult.Error);
|
||||
data.GetMemberData(target.ID).BannedUntil
|
||||
var memberData = data.GetMemberData(target.ID);
|
||||
memberData.BannedUntil
|
||||
= duration is not null ? DateTimeOffset.UtcNow.Add(duration.Value) : DateTimeOffset.MaxValue;
|
||||
|
||||
responseEmbed = new EmbedBuilder().WithSmallTitle(
|
||||
|
@ -120,9 +124,15 @@ public class BanCommandGroup : CommandGroup {
|
|||
|
||||
if ((cfg.PublicFeedbackChannel is not 0 && cfg.PublicFeedbackChannel != channelId.Value)
|
||||
|| (cfg.PrivateFeedbackChannel is not 0 && cfg.PrivateFeedbackChannel != channelId.Value)) {
|
||||
var builder = new StringBuilder().AppendLine(string.Format(Messages.DescriptionActionReason, reason));
|
||||
if (duration is not null)
|
||||
builder.Append(
|
||||
string.Format(
|
||||
Messages.DescriptionActionExpiresAt, Markdown.Timestamp(memberData.BannedUntil.Value)));
|
||||
|
||||
var logEmbed = new EmbedBuilder().WithSmallTitle(
|
||||
string.Format(Messages.UserBanned, target.GetTag()), target)
|
||||
.WithDescription(string.Format(Messages.DescriptionUserPunished, reason))
|
||||
.WithDescription(builder.ToString())
|
||||
.WithActionFooter(user)
|
||||
.WithCurrentTimestamp()
|
||||
.WithColour(ColorsList.Red)
|
||||
|
@ -203,7 +213,7 @@ public class BanCommandGroup : CommandGroup {
|
|||
return Result.FromError(userResult);
|
||||
|
||||
var unbanResult = await _guildApi.RemoveGuildBanAsync(
|
||||
guildId.Value, target.ID, $"({user.GetTag()}) {reason.EncodeHeader()}",
|
||||
guildId.Value, target.ID, $"({user.GetTag()}) {reason}".EncodeHeader(),
|
||||
ct: CancellationToken);
|
||||
if (!unbanResult.IsSuccess)
|
||||
return Result.FromError(unbanResult.Error);
|
||||
|
@ -216,6 +226,7 @@ public class BanCommandGroup : CommandGroup {
|
|||
|| (cfg.PrivateFeedbackChannel is not 0 && cfg.PrivateFeedbackChannel != channelId.Value)) {
|
||||
var logEmbed = new EmbedBuilder().WithSmallTitle(
|
||||
string.Format(Messages.UserUnbanned, target.GetTag()), target)
|
||||
.WithDescription(string.Format(Messages.DescriptionActionReason, reason))
|
||||
.WithActionFooter(user)
|
||||
.WithCurrentTimestamp()
|
||||
.WithColour(ColorsList.Green)
|
||||
|
|
|
@ -102,7 +102,7 @@ public class KickCommandGroup : CommandGroup {
|
|||
return Result.FromError(userResult);
|
||||
|
||||
var kickResult = await _guildApi.RemoveGuildMemberAsync(
|
||||
guildId.Value, target.ID, reason: $"({user.GetTag()}) {reason.EncodeHeader()}",
|
||||
guildId.Value, target.ID, $"({user.GetTag()}) {reason}".EncodeHeader(),
|
||||
ct: CancellationToken);
|
||||
if (!kickResult.IsSuccess)
|
||||
return Result.FromError(kickResult.Error);
|
||||
|
@ -115,7 +115,7 @@ public class KickCommandGroup : CommandGroup {
|
|||
|| (cfg.PrivateFeedbackChannel is not 0 && cfg.PrivateFeedbackChannel != channelId.Value)) {
|
||||
var logEmbed = new EmbedBuilder().WithSmallTitle(
|
||||
string.Format(Messages.UserKicked, target.GetTag()), target)
|
||||
.WithDescription(string.Format(Messages.DescriptionUserPunished, reason))
|
||||
.WithDescription(string.Format(Messages.DescriptionActionReason, reason))
|
||||
.WithActionFooter(user)
|
||||
.WithCurrentTimestamp()
|
||||
.WithColour(ColorsList.Red)
|
||||
|
|
1961
Messages.Designer.cs
generated
1961
Messages.Designer.cs
generated
File diff suppressed because it is too large
Load diff
|
@ -507,7 +507,10 @@
|
|||
<data name="UserKicked" xml:space="preserve">
|
||||
<value>{0} was kicked</value>
|
||||
</data>
|
||||
<data name="DescriptionUserPunished" xml:space="preserve">
|
||||
<data name="DescriptionActionReason" xml:space="preserve">
|
||||
<value>Reason: {0}</value>
|
||||
</data>
|
||||
<data name="DescriptionActionExpiresAt" xml:space="preserve">
|
||||
<value>Expires at: {0}</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
|
@ -507,7 +507,10 @@
|
|||
<data name="UserKicked" xml:space="preserve">
|
||||
<value>{0} был(-а) выгнан(-а)</value>
|
||||
</data>
|
||||
<data name="DescriptionUserPunished" xml:space="preserve">
|
||||
<data name="DescriptionActionReason" xml:space="preserve">
|
||||
<value>Причина: {0}</value>
|
||||
</data>
|
||||
<data name="DescriptionActionExpiresAt" xml:space="preserve">
|
||||
<value>Закончится: {0}</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
|
@ -507,7 +507,10 @@
|
|||
<data name="UserKicked" xml:space="preserve">
|
||||
<value>{0} вышел с посторонней помощью</value>
|
||||
</data>
|
||||
<data name="DescriptionUserPunished" xml:space="preserve">
|
||||
<data name="DescriptionActionReason" xml:space="preserve">
|
||||
<value>причина: {0}</value>
|
||||
</data>
|
||||
<data name="DescriptionActionExpiresAt" xml:space="preserve">
|
||||
<value>заживёт: {0}</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue