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>

View file

@ -28,7 +28,7 @@ namespace Boyfriend {
internal static System.Resources.ResourceManager ResourceManager { internal static System.Resources.ResourceManager ResourceManager {
get { get {
if (object.Equals(null, resourceMan)) { if (object.Equals(null, resourceMan)) {
System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Boyfriend.Messages", typeof(Messages).Assembly); System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Boyfriend.locale.Messages", typeof(Messages).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;

View file

@ -65,8 +65,7 @@ public class BanCommandGroup : CommandGroup {
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"));
@ -200,8 +199,7 @@ public class BanCommandGroup : CommandGroup {
[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) {