mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-04 08:34:27 -05:00 
			
		
		
		
	Added .expraddserver (.exas) which will server as a server-only alternative to '.exa' in case users want to override default Admin permissions with .dpo
This commit is contained in:
		@@ -1,7 +1,5 @@
 | 
			
		||||
#nullable disable
 | 
			
		||||
 | 
			
		||||
using Nadeko.Common;
 | 
			
		||||
 | 
			
		||||
namespace NadekoBot.Modules.NadekoExpressions;
 | 
			
		||||
 | 
			
		||||
[Name("Expressions")]
 | 
			
		||||
@@ -25,15 +23,10 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
 | 
			
		||||
        => (ctx.Guild is null && _creds.IsOwner(ctx.User))
 | 
			
		||||
           || (ctx.Guild is not null && ((IGuildUser)ctx.User).GuildPermissions.Administrator);
 | 
			
		||||
 | 
			
		||||
    [Cmd]
 | 
			
		||||
    public async Task ExprAdd(string key, [Leftover] string message)
 | 
			
		||||
    private async Task ExprAddInternalAsync(string key, string message)
 | 
			
		||||
    {
 | 
			
		||||
        if (string.IsNullOrWhiteSpace(message) || string.IsNullOrWhiteSpace(key))
 | 
			
		||||
            return;
 | 
			
		||||
 | 
			
		||||
        if (!AdminInGuildOrOwnerInDm())
 | 
			
		||||
        {
 | 
			
		||||
            await ReplyErrorLocalizedAsync(strs.expr_insuff_perms);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -48,12 +41,43 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
 | 
			
		||||
                                            message.Length > 1024 ? GetText(strs.redacted_too_long) : message));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [Cmd]
 | 
			
		||||
    [UserPerm(GuildPerm.Administrator)]
 | 
			
		||||
    public async Task ExprAddServer(string key, [Leftover] string message)
 | 
			
		||||
    {
 | 
			
		||||
        if (string.IsNullOrWhiteSpace(message) || string.IsNullOrWhiteSpace(key))
 | 
			
		||||
        {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        await ExprAddInternalAsync(key, message);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [Cmd]
 | 
			
		||||
    public async Task ExprAdd(string key, [Leftover] string message)
 | 
			
		||||
    {
 | 
			
		||||
        if (string.IsNullOrWhiteSpace(message) || string.IsNullOrWhiteSpace(key))
 | 
			
		||||
        {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!AdminInGuildOrOwnerInDm())
 | 
			
		||||
        {
 | 
			
		||||
            await ReplyErrorLocalizedAsync(strs.expr_insuff_perms);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        await ExprAddInternalAsync(key, message);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [Cmd]
 | 
			
		||||
    public async Task ExprEdit(kwum id, [Leftover] string message)
 | 
			
		||||
    {
 | 
			
		||||
        var channel = ctx.Channel as ITextChannel;
 | 
			
		||||
        if (string.IsNullOrWhiteSpace(message) || id < 0)
 | 
			
		||||
        {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ((channel is null && !_creds.IsOwner(ctx.User))
 | 
			
		||||
            || (channel is not null && !((IGuildUser)ctx.User).GuildPermissions.Administrator))
 | 
			
		||||
@@ -74,7 +98,9 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
 | 
			
		||||
                                                message.Length > 1024 ? GetText(strs.redacted_too_long) : message));
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            await ReplyErrorLocalizedAsync(strs.expr_no_found_id);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [Cmd]
 | 
			
		||||
@@ -82,7 +108,9 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
 | 
			
		||||
    public async Task ExprList(int page = 1)
 | 
			
		||||
    {
 | 
			
		||||
        if (--page < 0 || page > 999)
 | 
			
		||||
        {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var expressions = _service.GetExpressionsFor(ctx.Guild?.Id);
 | 
			
		||||
 | 
			
		||||
@@ -153,7 +181,9 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
 | 
			
		||||
                                            .AddField(GetText(strs.response), ex.Response.TrimTo(1024)));
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            await ReplyErrorLocalizedAsync(strs.expr_no_found_id);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [Cmd]
 | 
			
		||||
@@ -192,7 +222,9 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
 | 
			
		||||
                succ.Add(emojiStr);
 | 
			
		||||
 | 
			
		||||
                if (succ.Count >= 3)
 | 
			
		||||
                {
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            catch { }
 | 
			
		||||
        }
 | 
			
		||||
@@ -336,4 +368,4 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
 | 
			
		||||
 | 
			
		||||
        await ctx.OkAsync();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@@ -14,7 +14,7 @@ public sealed class QuoteService : IQuoteService, INService
 | 
			
		||||
    {
 | 
			
		||||
        _db = db;
 | 
			
		||||
    }
 | 
			
		||||
        
 | 
			
		||||
    
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Delete all quotes created by the author in a guild
 | 
			
		||||
    /// </summary>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user