1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-19 08:23:35 +03:00

Fix rebase errors

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-12-31 17:43:27 +05:00
parent 34186c22b5
commit 84469816d2
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
3 changed files with 28 additions and 17 deletions

View file

@ -10,7 +10,6 @@ using Octobot.Services.Profiler;
using Octobot.Services.Update;
using Remora.Commands.Attributes;
using Remora.Commands.Groups;
using Remora.Commands.Parsers;
using Remora.Discord.API.Abstractions.Objects;
using Remora.Discord.API.Abstractions.Rest;
using Remora.Discord.Commands.Attributes;
@ -123,22 +122,28 @@ public class BanCommandGroup : CommandGroup
if (stringDuration is null)
{
return await BanUserAsync(executor, target, reason, null, guild, data, channelId, bot,
CancellationToken);
_profiler.Pop();
return _profiler.ReportWithResult(await BanUserAsync(executor, target, reason, null, guild, data, channelId,
bot,
CancellationToken));
}
var parseResult = TimeSpanParser.TryParse(stringDuration);
if (!parseResult.IsDefined(out var duration))
{
_profiler.Push("invalid_timespan_send");
var failedEmbed = new EmbedBuilder()
.WithSmallTitle(Messages.InvalidTimeSpan, bot)
.WithColour(ColorsList.Red)
.Build();
return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: CancellationToken);
return _profiler.ReportWithResult(
await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: CancellationToken));
}
return await BanUserAsync(executor, target, reason, duration, guild, data, channelId, bot, CancellationToken);
_profiler.Pop();
return _profiler.ReportWithResult(await BanUserAsync(executor, target, reason, duration, guild, data, channelId,
bot, CancellationToken));
}
private async Task<Result> BanUserAsync(

View file

@ -122,18 +122,23 @@ public class MuteCommandGroup : CommandGroup
await _feedback.SendContextualEmbedResultAsync(embed, ct: CancellationToken));
}
_profiler.Pop();
var parseResult = TimeSpanParser.TryParse(stringDuration);
if (!parseResult.IsDefined(out var duration))
{
_profiler.Push("invalid_timespan_send");
var failedEmbed = new EmbedBuilder()
.WithSmallTitle(Messages.InvalidTimeSpan, bot)
.WithColour(ColorsList.Red)
.Build();
return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: CancellationToken);
return _profiler.ReportWithResult(
await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: CancellationToken));
}
return await MuteUserAsync(executor, target, reason, duration, guildId, data, channelId, bot, CancellationToken);
_profiler.Pop();
return _profiler.ReportWithResult(await MuteUserAsync(executor, target, reason, duration, guildId, data,
channelId, bot, CancellationToken));
}
private async Task<Result> MuteUserAsync(

View file

@ -4,6 +4,7 @@ using System.Text;
using JetBrains.Annotations;
using Octobot.Data;
using Octobot.Extensions;
using Octobot.Parsers;
using Octobot.Services;
using Octobot.Services.Profiler;
using Remora.Commands.Attributes;
@ -18,7 +19,6 @@ using Remora.Discord.Extensions.Embeds;
using Remora.Discord.Extensions.Formatting;
using Remora.Rest.Core;
using Remora.Results;
using Octobot.Parsers;
namespace Octobot.Commands;
@ -143,8 +143,7 @@ public class RemindCommandGroup : CommandGroup
[RequireContext(ChannelContext.Guild)]
[UsedImplicitly]
public async Task<Result> ExecuteReminderAsync(
[Description("After what period of time mention the reminder")]
[Option("in")]
[Description("After what period of time mention the reminder")] [Option("in")]
string timeSpanString,
[Description("Reminder text")] [MaxLength(512)]
string text)
@ -157,12 +156,14 @@ public class RemindCommandGroup : CommandGroup
"Unable to retrieve necessary IDs from command context"));
}
_profiler.Push("current_get");
var botResult = await _userApi.GetCurrentUserAsync(CancellationToken);
if (!botResult.IsDefined(out var bot))
{
return Result.FromError(botResult);
}
_profiler.Pop();
_profiler.Push("executor_get");
var executorResult = await _userApi.GetUserAsync(executorId, CancellationToken);
if (!executorResult.IsDefined(out var executor))
@ -179,19 +180,19 @@ public class RemindCommandGroup : CommandGroup
var parseResult = TimeSpanParser.TryParse(timeSpanString);
if (!parseResult.IsDefined(out var timeSpan))
{
_profiler.Push("invalid_timespan_send");
var failedEmbed = new EmbedBuilder()
.WithSmallTitle(Messages.InvalidTimeSpan, bot)
.WithColour(ColorsList.Red)
.Build();
return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: CancellationToken);
return _profiler.ReportWithResult(
await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: CancellationToken));
}
_profiler.Pop();
return _profiler.ReportWithResult(await AddReminderAsync(@in, text, data, channelId, executor,
CancellationToken));
}
return await AddReminderAsync(timeSpan, text, data, channelId, executor, CancellationToken);
_profiler.Pop();
return _profiler.ReportWithResult(await AddReminderAsync(timeSpan, text, data, channelId, executor,
CancellationToken));
}
private async Task<Result> AddReminderAsync(TimeSpan timeSpan, string text, GuildData data,
@ -199,7 +200,7 @@ public class RemindCommandGroup : CommandGroup
{
_profiler.Push("main");
var memberData = data.GetOrCreateMemberData(executor.ID);
var remindAt = DateTimeOffset.UtcNow.Add(@in);
var remindAt = DateTimeOffset.UtcNow.Add(timeSpan);
_profiler.Push("original_response_get");
var responseResult =