From b1e6e93fe4e0bd09d4319de77dc27a4123593c24 Mon Sep 17 00:00:00 2001 From: Toastie Date: Sun, 12 May 2024 23:43:23 +1200 Subject: [PATCH] Updated Ellie.Marmalade --- .../Attributes/FilterAttribute.cs | 2 +- .../Attributes/MarmaladePermAttribute.cs | 2 +- .../Attributes/bot_owner_onlyAttribute.cs | 2 +- .../Attributes/bot_permAttribute.cs | 2 +- .../Attributes/cmdAttribute.cs | 2 +- .../Attributes/injectAttribute.cs | 2 +- .../Attributes/leftoverAttribute.cs | 2 +- .../Attributes/prioAttribute.cs | 2 +- .../Attributes/svcAttribute.cs | 2 +- .../Attributes/user_permAttribute.cs | 2 +- src/Ellie.Marmalade/Canary.cs | 2 +- src/Ellie.Marmalade/Context/AnyContext.cs | 11 +------ src/Ellie.Marmalade/Context/DmContext.cs | 2 +- src/Ellie.Marmalade/Context/GuildContext.cs | 2 +- src/Ellie.Marmalade/Ellie.Marmalade.csproj | 13 ++++----- .../Extensions/EmbedBuilderExtensions.cs | 14 --------- .../Extensions/MarmaladeExtensions.cs | 29 ++++++++----------- .../ParamParser/ParamParser.cs | 2 +- .../ParamParser/ParseResult.cs | 2 +- src/Ellie.Marmalade/Strings/CommandStrings.cs | 2 +- .../Strings/IMarmaladeStrings.cs | 2 +- .../Strings/IMarmaladeStringsProvider.cs | 2 +- .../Strings/LocalMarmaladeStringsProvider.cs | 2 +- .../Strings/MarmaladeStrings.cs | 2 +- src/Ellie.Marmalade/Strings/StringsLoader.cs | 2 +- 25 files changed, 39 insertions(+), 70 deletions(-) delete mode 100644 src/Ellie.Marmalade/Extensions/EmbedBuilderExtensions.cs diff --git a/src/Ellie.Marmalade/Attributes/FilterAttribute.cs b/src/Ellie.Marmalade/Attributes/FilterAttribute.cs index de6ae24..d5a428b 100644 --- a/src/Ellie.Marmalade/Attributes/FilterAttribute.cs +++ b/src/Ellie.Marmalade/Attributes/FilterAttribute.cs @@ -1,4 +1,4 @@ -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; /// /// Overridden to implement custom checks which commands have to pass in order to be executed. diff --git a/src/Ellie.Marmalade/Attributes/MarmaladePermAttribute.cs b/src/Ellie.Marmalade/Attributes/MarmaladePermAttribute.cs index 0001d76..0f04c23 100644 --- a/src/Ellie.Marmalade/Attributes/MarmaladePermAttribute.cs +++ b/src/Ellie.Marmalade/Attributes/MarmaladePermAttribute.cs @@ -1,4 +1,4 @@ -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; /// /// Used as a marker class for bot_perm and user_perm Attributes diff --git a/src/Ellie.Marmalade/Attributes/bot_owner_onlyAttribute.cs b/src/Ellie.Marmalade/Attributes/bot_owner_onlyAttribute.cs index 8186614..31c3cfd 100644 --- a/src/Ellie.Marmalade/Attributes/bot_owner_onlyAttribute.cs +++ b/src/Ellie.Marmalade/Attributes/bot_owner_onlyAttribute.cs @@ -1,4 +1,4 @@ -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; [AttributeUsage(AttributeTargets.Method)] public sealed class bot_owner_onlyAttribute : MarmaladePermAttribute diff --git a/src/Ellie.Marmalade/Attributes/bot_permAttribute.cs b/src/Ellie.Marmalade/Attributes/bot_permAttribute.cs index 30fa320..6bd6af1 100644 --- a/src/Ellie.Marmalade/Attributes/bot_permAttribute.cs +++ b/src/Ellie.Marmalade/Attributes/bot_permAttribute.cs @@ -1,6 +1,6 @@ using Discord; -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] public sealed class bot_permAttribute : MarmaladePermAttribute diff --git a/src/Ellie.Marmalade/Attributes/cmdAttribute.cs b/src/Ellie.Marmalade/Attributes/cmdAttribute.cs index 56ce03b..0dc068e 100644 --- a/src/Ellie.Marmalade/Attributes/cmdAttribute.cs +++ b/src/Ellie.Marmalade/Attributes/cmdAttribute.cs @@ -1,4 +1,4 @@ -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; /// /// Marks a method as a snek command diff --git a/src/Ellie.Marmalade/Attributes/injectAttribute.cs b/src/Ellie.Marmalade/Attributes/injectAttribute.cs index 4865cff..be843ae 100644 --- a/src/Ellie.Marmalade/Attributes/injectAttribute.cs +++ b/src/Ellie.Marmalade/Attributes/injectAttribute.cs @@ -1,4 +1,4 @@ -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; /// /// Marks services in command arguments for injection. diff --git a/src/Ellie.Marmalade/Attributes/leftoverAttribute.cs b/src/Ellie.Marmalade/Attributes/leftoverAttribute.cs index b16c225..71543e2 100644 --- a/src/Ellie.Marmalade/Attributes/leftoverAttribute.cs +++ b/src/Ellie.Marmalade/Attributes/leftoverAttribute.cs @@ -1,4 +1,4 @@ -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; /// /// Marks the parameter to take diff --git a/src/Ellie.Marmalade/Attributes/prioAttribute.cs b/src/Ellie.Marmalade/Attributes/prioAttribute.cs index 9b1cc81..2868b23 100644 --- a/src/Ellie.Marmalade/Attributes/prioAttribute.cs +++ b/src/Ellie.Marmalade/Attributes/prioAttribute.cs @@ -1,4 +1,4 @@ -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; /// /// Sets the priority of a command in case there are multiple commands with the same name but different parameters. diff --git a/src/Ellie.Marmalade/Attributes/svcAttribute.cs b/src/Ellie.Marmalade/Attributes/svcAttribute.cs index dab065f..a453303 100644 --- a/src/Ellie.Marmalade/Attributes/svcAttribute.cs +++ b/src/Ellie.Marmalade/Attributes/svcAttribute.cs @@ -1,4 +1,4 @@ -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; /// /// Marks the class as a service which can be used within the same Medusa diff --git a/src/Ellie.Marmalade/Attributes/user_permAttribute.cs b/src/Ellie.Marmalade/Attributes/user_permAttribute.cs index 7d195eb..b0a3aa3 100644 --- a/src/Ellie.Marmalade/Attributes/user_permAttribute.cs +++ b/src/Ellie.Marmalade/Attributes/user_permAttribute.cs @@ -1,6 +1,6 @@ using Discord; -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] public sealed class user_permAttribute : MarmaladePermAttribute diff --git a/src/Ellie.Marmalade/Canary.cs b/src/Ellie.Marmalade/Canary.cs index 6fef82c..4b7bbbb 100644 --- a/src/Ellie.Marmalade/Canary.cs +++ b/src/Ellie.Marmalade/Canary.cs @@ -1,6 +1,6 @@ using Discord; -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; /// /// The base class which will be loaded as a module into EllieBot diff --git a/src/Ellie.Marmalade/Context/AnyContext.cs b/src/Ellie.Marmalade/Context/AnyContext.cs index 816a95d..4f7207c 100644 --- a/src/Ellie.Marmalade/Context/AnyContext.cs +++ b/src/Ellie.Marmalade/Context/AnyContext.cs @@ -1,7 +1,7 @@ using Discord; using EllieBot; -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; /// /// Commands which take this class as a first parameter can be executed in both DMs and Servers @@ -40,13 +40,4 @@ public abstract class AnyContext /// Arguments (if any) to format in /// A formatted localized string public abstract string GetText(string key, object[]? args = null); - - /// - /// Creates a context-aware instance - /// (future feature for guild-based embed colors) - /// Any code dealing with embeds should use it for future-proofness - /// instead of manually creating embedbuilder instances - /// - /// A context-aware instance - public abstract IEmbedBuilder Embed(); } \ No newline at end of file diff --git a/src/Ellie.Marmalade/Context/DmContext.cs b/src/Ellie.Marmalade/Context/DmContext.cs index a703fa4..d971ee5 100644 --- a/src/Ellie.Marmalade/Context/DmContext.cs +++ b/src/Ellie.Marmalade/Context/DmContext.cs @@ -1,6 +1,6 @@ using Discord; -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; /// /// Commands which take this type as the first parameter can only be executed in DMs diff --git a/src/Ellie.Marmalade/Context/GuildContext.cs b/src/Ellie.Marmalade/Context/GuildContext.cs index 33cca4f..63ca873 100644 --- a/src/Ellie.Marmalade/Context/GuildContext.cs +++ b/src/Ellie.Marmalade/Context/GuildContext.cs @@ -1,6 +1,6 @@ using Discord; -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; /// /// Commands which take this type as a first parameter can only be executed in a server diff --git a/src/Ellie.Marmalade/Ellie.Marmalade.csproj b/src/Ellie.Marmalade/Ellie.Marmalade.csproj index aa15438..b01a911 100644 --- a/src/Ellie.Marmalade/Ellie.Marmalade.csproj +++ b/src/Ellie.Marmalade/Ellie.Marmalade.csproj @@ -1,24 +1,21 @@ - net6.0 + net8.0 enable enable - preview - true - Ellie.Marmalade The EllieBot Devs - - - + + + - 5.0.0 + 9.0.0 diff --git a/src/Ellie.Marmalade/Extensions/EmbedBuilderExtensions.cs b/src/Ellie.Marmalade/Extensions/EmbedBuilderExtensions.cs deleted file mode 100644 index 6b6d50d..0000000 --- a/src/Ellie.Marmalade/Extensions/EmbedBuilderExtensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace EllieBot; - -public static class EmbedBuilderExtensions -{ - public static IEmbedBuilder WithOkColor(this IEmbedBuilder eb) - => eb.WithColor(EmbedColor.Ok); - - public static IEmbedBuilder WithPendingColor(this IEmbedBuilder eb) - => eb.WithColor(EmbedColor.Pending); - - public static IEmbedBuilder WithErrorColor(this IEmbedBuilder eb) - => eb.WithColor(EmbedColor.Error); - -} diff --git a/src/Ellie.Marmalade/Extensions/MarmaladeExtensions.cs b/src/Ellie.Marmalade/Extensions/MarmaladeExtensions.cs index c02f973..1047966 100644 --- a/src/Ellie.Marmalade/Extensions/MarmaladeExtensions.cs +++ b/src/Ellie.Marmalade/Extensions/MarmaladeExtensions.cs @@ -1,11 +1,10 @@ using Discord; -using Ellie.Marmalade; -namespace EllieBot; +namespace EllieBot.Marmalade; public static class MarmaladeExtensions { - public static Task EmbedAsync(this IMessageChannel ch, IEmbedBuilder embed, string msg = "") + public static Task EmbedAsync(this IMessageChannel ch, EmbedBuilder embed, string msg = "") => ch.SendMessageAsync(msg, embed: embed.Build(), options: new() @@ -13,25 +12,21 @@ public static class MarmaladeExtensions RetryMode = RetryMode.Retry502 }); - // unlocalized - public static Task SendConfirmAsync(this IMessageChannel ch, AnyContext ctx, string msg) - => ch.EmbedAsync(ctx.Embed().WithOkColor().WithDescription(msg)); - - public static Task SendPendingAsync(this IMessageChannel ch, AnyContext ctx, string msg) - => ch.EmbedAsync(ctx.Embed().WithPendingColor().WithDescription(msg)); - - public static Task SendErrorAsync(this IMessageChannel ch, AnyContext ctx, string msg) - => ch.EmbedAsync(ctx.Embed().WithErrorColor().WithDescription(msg)); - // unlocalized public static Task SendConfirmAsync(this AnyContext ctx, string msg) - => ctx.Channel.SendConfirmAsync(ctx, msg); + => ctx.Channel.EmbedAsync(new EmbedBuilder() + .WithColor(0, 200, 0) + .WithDescription(msg)); public static Task SendPendingAsync(this AnyContext ctx, string msg) - => ctx.Channel.SendPendingAsync(ctx, msg); + => ctx.Channel.EmbedAsync(new EmbedBuilder() + .WithColor(200, 200, 0) + .WithDescription(msg)); public static Task SendErrorAsync(this AnyContext ctx, string msg) - => ctx.Channel.SendErrorAsync(ctx, msg); + => ctx.Channel.EmbedAsync(new EmbedBuilder() + .WithColor(200, 0, 0) + .WithDescription(msg)); // localized public static Task ConfirmAsync(this AnyContext ctx) @@ -63,4 +58,4 @@ public static class MarmaladeExtensions public static Task ReplyConfirmLocalizedAsync(this AnyContext ctx, string key, params object[]? args) => ctx.SendConfirmAsync($"{Format.Bold(ctx.User.ToString())} {ctx.GetText(key, args)}"); -} +} \ No newline at end of file diff --git a/src/Ellie.Marmalade/ParamParser/ParamParser.cs b/src/Ellie.Marmalade/ParamParser/ParamParser.cs index a174a78..e4758d6 100644 --- a/src/Ellie.Marmalade/ParamParser/ParamParser.cs +++ b/src/Ellie.Marmalade/ParamParser/ParamParser.cs @@ -1,4 +1,4 @@ -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; /// /// Overridden to implement parsers for custom types diff --git a/src/Ellie.Marmalade/ParamParser/ParseResult.cs b/src/Ellie.Marmalade/ParamParser/ParseResult.cs index e12b77e..24c115b 100644 --- a/src/Ellie.Marmalade/ParamParser/ParseResult.cs +++ b/src/Ellie.Marmalade/ParamParser/ParseResult.cs @@ -1,4 +1,4 @@ -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; public readonly struct ParseResult { diff --git a/src/Ellie.Marmalade/Strings/CommandStrings.cs b/src/Ellie.Marmalade/Strings/CommandStrings.cs index 5d06f3c..056d028 100644 --- a/src/Ellie.Marmalade/Strings/CommandStrings.cs +++ b/src/Ellie.Marmalade/Strings/CommandStrings.cs @@ -1,6 +1,6 @@ using YamlDotNet.Serialization; -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; public readonly struct CommandStrings { diff --git a/src/Ellie.Marmalade/Strings/IMarmaladeStrings.cs b/src/Ellie.Marmalade/Strings/IMarmaladeStrings.cs index 37c4299..f76cf82 100644 --- a/src/Ellie.Marmalade/Strings/IMarmaladeStrings.cs +++ b/src/Ellie.Marmalade/Strings/IMarmaladeStrings.cs @@ -1,6 +1,6 @@ using System.Globalization; -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; /// /// Defines methods to retrieve and reload marmalade strings diff --git a/src/Ellie.Marmalade/Strings/IMarmaladeStringsProvider.cs b/src/Ellie.Marmalade/Strings/IMarmaladeStringsProvider.cs index 6df86b0..2845f94 100644 --- a/src/Ellie.Marmalade/Strings/IMarmaladeStringsProvider.cs +++ b/src/Ellie.Marmalade/Strings/IMarmaladeStringsProvider.cs @@ -1,4 +1,4 @@ -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; /// /// Implemented by classes which provide localized strings in their own ways diff --git a/src/Ellie.Marmalade/Strings/LocalMarmaladeStringsProvider.cs b/src/Ellie.Marmalade/Strings/LocalMarmaladeStringsProvider.cs index 0ea98d5..3b02ca6 100644 --- a/src/Ellie.Marmalade/Strings/LocalMarmaladeStringsProvider.cs +++ b/src/Ellie.Marmalade/Strings/LocalMarmaladeStringsProvider.cs @@ -1,4 +1,4 @@ -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; public class LocalMarmaladeStringsProvider : IMarmaladeStringsProvider { diff --git a/src/Ellie.Marmalade/Strings/MarmaladeStrings.cs b/src/Ellie.Marmalade/Strings/MarmaladeStrings.cs index 286e9a1..c4f9f26 100644 --- a/src/Ellie.Marmalade/Strings/MarmaladeStrings.cs +++ b/src/Ellie.Marmalade/Strings/MarmaladeStrings.cs @@ -1,7 +1,7 @@ using System.Globalization; using Serilog; -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; public class MarmaladeStrings : IMarmaladeStrings { diff --git a/src/Ellie.Marmalade/Strings/StringsLoader.cs b/src/Ellie.Marmalade/Strings/StringsLoader.cs index 986fcad..e9b2493 100644 --- a/src/Ellie.Marmalade/Strings/StringsLoader.cs +++ b/src/Ellie.Marmalade/Strings/StringsLoader.cs @@ -2,7 +2,7 @@ using Serilog; using YamlDotNet.Serialization; -namespace Ellie.Marmalade; +namespace EllieBot.Marmalade; /// /// Loads strings from the shortcut or localizable path