1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-20 00:43:36 +03:00

I wish there were brackets for profilers

Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
Macintxsh 2024-01-27 16:00:10 +03:00
parent 4985cd6669
commit 70e04f3958
Signed by: mctaylors
GPG key ID: 7181BEBE676903C1

View file

@ -105,6 +105,7 @@ public class ToolsCommandGroup : CommandGroup
Messages.Culture = GuildSettings.Language.Get(data.Settings); Messages.Culture = GuildSettings.Language.Get(data.Settings);
_profiler.Pop(); _profiler.Pop();
_profiler.Pop();
return _profiler.ReportWithResult(await ShowUserInfoAsync(target ?? executor, bot, data, guildId, CancellationToken)); return _profiler.ReportWithResult(await ShowUserInfoAsync(target ?? executor, bot, data, guildId, CancellationToken));
} }
@ -128,7 +129,7 @@ public class ToolsCommandGroup : CommandGroup
var embedColor = ColorsList.Cyan; var embedColor = ColorsList.Cyan;
_profiler.Push("member_guild_get"); _profiler.Push("guild_member_get");
var guildMemberResult = await _guildApi.GetGuildMemberAsync(guildId, target.ID, ct); var guildMemberResult = await _guildApi.GetGuildMemberAsync(guildId, target.ID, ct);
_profiler.Pop(); _profiler.Pop();
DateTimeOffset? communicationDisabledUntil = null; DateTimeOffset? communicationDisabledUntil = null;
@ -146,13 +147,11 @@ public class ToolsCommandGroup : CommandGroup
if (wasMuted || wasBanned || wasKicked) if (wasMuted || wasBanned || wasKicked)
{ {
_profiler.Push("append_punishments");
builder.Append("### ") builder.Append("### ")
.AppendLine(Markdown.Bold(Messages.UserInfoPunishments)); .AppendLine(Markdown.Bold(Messages.UserInfoPunishments));
embedColor = AppendPunishmentsInformation(wasMuted, wasKicked, wasBanned, memberData, embedColor = AppendPunishmentsInformation(wasMuted, wasKicked, wasBanned, memberData,
builder, embedColor, communicationDisabledUntil); builder, embedColor, communicationDisabledUntil);
_profiler.Pop();
} }
if (!guildMemberResult.IsSuccess && !wasBanned) if (!guildMemberResult.IsSuccess && !wasBanned)
@ -173,7 +172,6 @@ public class ToolsCommandGroup : CommandGroup
.WithFooter($"ID: {target.ID.ToString()}") .WithFooter($"ID: {target.ID.ToString()}")
.Build(); .Build();
_profiler.Pop();
return _profiler.PopWithResult(await _feedback.SendContextualEmbedResultAsync(embed, ct: ct)); return _profiler.PopWithResult(await _feedback.SendContextualEmbedResultAsync(embed, ct: ct));
} }
@ -316,6 +314,7 @@ public class ToolsCommandGroup : CommandGroup
Messages.Culture = GuildSettings.Language.Get(data.Settings); Messages.Culture = GuildSettings.Language.Get(data.Settings);
_profiler.Pop(); _profiler.Pop();
_profiler.Pop();
return _profiler.ReportWithResult(await ShowGuildInfoAsync(bot, guild, CancellationToken)); return _profiler.ReportWithResult(await ShowGuildInfoAsync(bot, guild, CancellationToken));
} }
@ -359,7 +358,6 @@ public class ToolsCommandGroup : CommandGroup
.WithFooter($"ID: {guild.ID.ToString()}") .WithFooter($"ID: {guild.ID.ToString()}")
.Build(); .Build();
_profiler.Pop();
return _profiler.PopWithResult(_feedback.SendContextualEmbedResultAsync(embed, ct: ct)); return _profiler.PopWithResult(_feedback.SendContextualEmbedResultAsync(embed, ct: ct));
} }
@ -388,7 +386,6 @@ public class ToolsCommandGroup : CommandGroup
"Unable to retrieve necessary IDs from command context")); "Unable to retrieve necessary IDs from command context"));
} }
_profiler.Pop();
_profiler.Push("executor_get"); _profiler.Push("executor_get");
var executorResult = await _userApi.GetUserAsync(executorId, CancellationToken); var executorResult = await _userApi.GetUserAsync(executorId, CancellationToken);
if (!executorResult.IsDefined(out var executor)) if (!executorResult.IsDefined(out var executor))
@ -402,6 +399,7 @@ public class ToolsCommandGroup : CommandGroup
Messages.Culture = GuildSettings.Language.Get(data.Settings); Messages.Culture = GuildSettings.Language.Get(data.Settings);
_profiler.Pop(); _profiler.Pop();
_profiler.Pop();
return _profiler.ReportWithResult(await SendRandomNumberAsync(first, second, executor, CancellationToken)); return _profiler.ReportWithResult(await SendRandomNumberAsync(first, second, executor, CancellationToken));
} }
@ -409,7 +407,6 @@ public class ToolsCommandGroup : CommandGroup
IUser executor, CancellationToken ct) IUser executor, CancellationToken ct)
{ {
_profiler.Push("main"); _profiler.Push("main");
_profiler.Push("random_number_get");
const long secondDefault = 0; const long secondDefault = 0;
var second = secondNullable ?? secondDefault; var second = secondNullable ?? secondDefault;
@ -418,7 +415,6 @@ public class ToolsCommandGroup : CommandGroup
var i = Random.Shared.NextInt64(min, max + 1); var i = Random.Shared.NextInt64(min, max + 1);
_profiler.Pop();
_profiler.Push("builder_construction"); _profiler.Push("builder_construction");
var description = new StringBuilder().Append("# ").Append(i); var description = new StringBuilder().Append("# ").Append(i);
@ -451,7 +447,6 @@ public class ToolsCommandGroup : CommandGroup
.WithColour(embedColor) .WithColour(embedColor)
.Build(); .Build();
_profiler.Pop();
return _profiler.PopWithResult(_feedback.SendContextualEmbedResultAsync(embed, ct: ct)); return _profiler.PopWithResult(_feedback.SendContextualEmbedResultAsync(embed, ct: ct));
} }
@ -560,7 +555,6 @@ public class ToolsCommandGroup : CommandGroup
.WithColour(ColorsList.Blue) .WithColour(ColorsList.Blue)
.Build(); .Build();
_profiler.Pop();
return _profiler.PopWithResult(_feedback.SendContextualEmbedResultAsync(embed, ct: ct)); return _profiler.PopWithResult(_feedback.SendContextualEmbedResultAsync(embed, ct: ct));
} }
} }