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

Tidy up project structure, fix bug with edit logging

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-07-09 21:49:47 +05:00
parent 2dd9f023ef
commit 507d5fd58f
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
27 changed files with 178 additions and 175 deletions

View file

@ -23,8 +23,9 @@
<PackageReference Include="Humanizer.Core.ru" Version="2.14.1"/> <PackageReference Include="Humanizer.Core.ru" Version="2.14.1"/>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1"/> <PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1"/>
<PackageReference Include="Remora.Discord" Version="2023.3.0"/> <PackageReference Include="Remora.Discord" Version="2023.3.0"/>
</ItemGroup>
<EmbeddedResource Update="Messages.resx"> <ItemGroup>
<EmbeddedResource Update="locale\Messages.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Messages.Designer.cs</LastGenOutput> <LastGenOutput>Messages.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>

File diff suppressed because it is too large Load diff

View file

@ -59,8 +59,8 @@ public class AboutCommandGroup : CommandGroup {
builder.AppendLine($"@{dev} — {$"AboutDeveloper@{dev}".Localized()}"); builder.AppendLine($"@{dev} — {$"AboutDeveloper@{dev}".Localized()}");
builder.AppendLine() builder.AppendLine()
.AppendLine(Markdown.Bold(Messages.AboutTitleWiki)) .AppendLine(Markdown.Bold(Messages.AboutTitleWiki))
.AppendLine("https://github.com/TeamOctolings/Boyfriend/wiki"); .AppendLine("https://github.com/TeamOctolings/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

@ -63,10 +63,9 @@ public class BanCommandGroup : CommandGroup {
[RequireBotDiscordPermissions(DiscordPermission.BanMembers)] [RequireBotDiscordPermissions(DiscordPermission.BanMembers)]
[Description("Ban user")] [Description("Ban user")]
public async Task<Result> BanUserAsync( public async Task<Result> BanUserAsync(
[Description("User to ban")] IUser target, [Description("User to ban")] IUser target,
[Description("Ban reason")] string reason, [Description("Ban reason")] string reason,
[Description("Ban duration")] [Description("Ban duration")] TimeSpan? duration = null) {
TimeSpan? duration = null) {
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var userId)) if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var userId))
return Result.FromError( return Result.FromError(
new ArgumentNullError(nameof(_context), "Unable to retrieve necessary IDs from command context")); new ArgumentNullError(nameof(_context), "Unable to retrieve necessary IDs from command context"));
@ -199,9 +198,8 @@ public class BanCommandGroup : CommandGroup {
[RequireBotDiscordPermissions(DiscordPermission.BanMembers)] [RequireBotDiscordPermissions(DiscordPermission.BanMembers)]
[Description("Unban user")] [Description("Unban user")]
public async Task<Result> UnbanUserAsync( public async Task<Result> UnbanUserAsync(
[Description("User to unban")] IUser target, [Description("User to unban")] IUser target,
[Description("Unban reason")] [Description("Unban reason")] string reason) {
string reason) {
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var userId)) if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var userId))
return Result.FromError( return Result.FromError(
new ArgumentNullError(nameof(_context), "Unable to retrieve necessary IDs from command context")); new ArgumentNullError(nameof(_context), "Unable to retrieve necessary IDs from command context"));

View file

@ -125,13 +125,17 @@ public static class Extensions {
} }
/// <summary> /// <summary>
/// Sanitizes a string (see <see cref="SanitizeForBlockCode" />) and formats the string with block code. /// Sanitizes a string (see <see cref="SanitizeForBlockCode" />) and formats the string to use Markdown Block Code formatting with a specified
/// language for syntax highlighting.
/// </summary> /// </summary>
/// <param name="s">The string to sanitize and format.</param> /// <param name="s">The string to sanitize and format.</param>
/// <returns>The sanitized string formatted with <see cref="Markdown.BlockCode(string)" />.</returns> /// <param name="language"></param>
public static string InBlockCode(this string s) { /// <returns>The sanitized string formatted to use Markdown Block Code with a specified
/// language for syntax highlighting.</returns>
public static string InBlockCode(this string s, string language = "") {
s = s.SanitizeForBlockCode(); s = s.SanitizeForBlockCode();
return $"```{s.SanitizeForBlockCode()}{(s.EndsWith("`") || string.IsNullOrWhiteSpace(s) ? " " : "")}```"; return
$"```{language}\n{s.SanitizeForBlockCode()}{(s.EndsWith("`") || string.IsNullOrWhiteSpace(s) ? " " : "")}```";
} }
public static string Localized(this string key) { public static string Localized(this string key) {
@ -159,7 +163,7 @@ public static class Extensions {
builder.AppendLine(line.Text); builder.AppendLine(line.Text);
} }
return InBlockCode(builder.ToString()); return InBlockCode(builder.ToString(), "diff");
} }
public static string GetTag(this IUser user) { public static string GetTag(this IUser user) {