Updated Ellie.Marmalade
This commit is contained in:
parent
dac6e283e8
commit
b1e6e93fe4
25 changed files with 39 additions and 70 deletions
|
@ -1,4 +1,4 @@
|
|||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
/// <summary>
|
||||
/// Overridden to implement custom checks which commands have to pass in order to be executed.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
/// <summary>
|
||||
/// Used as a marker class for bot_perm and user_perm Attributes
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class bot_owner_onlyAttribute : MarmaladePermAttribute
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using Discord;
|
||||
|
||||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
||||
public sealed class bot_permAttribute : MarmaladePermAttribute
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
/// <summary>
|
||||
/// Marks a method as a snek command
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
/// <summary>
|
||||
/// Marks services in command arguments for injection.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
/// <summary>
|
||||
/// Marks the parameter to take
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the priority of a command in case there are multiple commands with the same name but different parameters.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
/// <summary>
|
||||
/// Marks the class as a service which can be used within the same Medusa
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using Discord;
|
||||
|
||||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
||||
public sealed class user_permAttribute : MarmaladePermAttribute
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using Discord;
|
||||
|
||||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
/// <summary>
|
||||
/// The base class which will be loaded as a module into EllieBot
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using Discord;
|
||||
using EllieBot;
|
||||
|
||||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
|||
/// <param name="args">Arguments (if any) to format in</param>
|
||||
/// <returns>A formatted localized string</returns>
|
||||
public abstract string GetText(string key, object[]? args = null);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a context-aware <see cref="IEmbedBuilder"/> 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
|
||||
/// </summary>
|
||||
/// <returns>A context-aware <see cref="IEmbedBuilder"/> instance </returns>
|
||||
public abstract IEmbedBuilder Embed();
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
using Discord;
|
||||
|
||||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
/// <summary>
|
||||
/// Commands which take this type as the first parameter can only be executed in DMs
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using Discord;
|
||||
|
||||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
/// <summary>
|
||||
/// Commands which take this type as a first parameter can only be executed in a server
|
||||
|
|
|
@ -1,24 +1,21 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>preview</LangVersion>
|
||||
<EnablePreviewFeatures>true</EnablePreviewFeatures>
|
||||
<RootNamespace>Ellie.Marmalade</RootNamespace>
|
||||
|
||||
<Authors>The EllieBot Devs</Authors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Discord.Net.Core" Version="3.104.0" />
|
||||
<PackageReference Include="Serilog" Version="2.11.0" />
|
||||
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
||||
<PackageReference Include="Discord.Net.Core" Version="3.204.0" />
|
||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||
<PackageReference Include="YamlDotNet" Version="15.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Version)' == '' ">
|
||||
<Version>5.0.0</Version>
|
||||
<Version>9.0.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -1,11 +1,10 @@
|
|||
using Discord;
|
||||
using Ellie.Marmalade;
|
||||
|
||||
namespace EllieBot;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
public static class MarmaladeExtensions
|
||||
{
|
||||
public static Task<IUserMessage> EmbedAsync(this IMessageChannel ch, IEmbedBuilder embed, string msg = "")
|
||||
public static Task<IUserMessage> 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<IUserMessage> SendConfirmAsync(this IMessageChannel ch, AnyContext ctx, string msg)
|
||||
=> ch.EmbedAsync(ctx.Embed().WithOkColor().WithDescription(msg));
|
||||
|
||||
public static Task<IUserMessage> SendPendingAsync(this IMessageChannel ch, AnyContext ctx, string msg)
|
||||
=> ch.EmbedAsync(ctx.Embed().WithPendingColor().WithDescription(msg));
|
||||
|
||||
public static Task<IUserMessage> SendErrorAsync(this IMessageChannel ch, AnyContext ctx, string msg)
|
||||
=> ch.EmbedAsync(ctx.Embed().WithErrorColor().WithDescription(msg));
|
||||
|
||||
// unlocalized
|
||||
public static Task<IUserMessage> 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<IUserMessage> 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<IUserMessage> 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<IUserMessage> ReplyConfirmLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
|
||||
=> ctx.SendConfirmAsync($"{Format.Bold(ctx.User.ToString())} {ctx.GetText(key, args)}");
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
/// <summary>
|
||||
/// Overridden to implement parsers for custom types
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
public readonly struct ParseResult<T>
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
public readonly struct CommandStrings
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System.Globalization;
|
||||
|
||||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
/// <summary>
|
||||
/// Defines methods to retrieve and reload marmalade strings
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
/// <summary>
|
||||
/// Implemented by classes which provide localized strings in their own ways
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
public class LocalMarmaladeStringsProvider : IMarmaladeStringsProvider
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Globalization;
|
||||
using Serilog;
|
||||
|
||||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
public class MarmaladeStrings : IMarmaladeStrings
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using Serilog;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace Ellie.Marmalade;
|
||||
namespace EllieBot.Marmalade;
|
||||
|
||||
/// <summary>
|
||||
/// Loads strings from the shortcut or localizable path
|
||||
|
|
Loading…
Reference in a new issue