mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-03 16:24: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>
 | 
			
		||||
 
 | 
			
		||||
@@ -37,7 +37,7 @@ boost:
 | 
			
		||||
boostmsg:
 | 
			
		||||
  - boostmsg
 | 
			
		||||
boostdel:
 | 
			
		||||
  - boostdel
 | 
			
		||||
  - boostde
 | 
			
		||||
logserver:
 | 
			
		||||
  - logserver
 | 
			
		||||
logignore:
 | 
			
		||||
@@ -1287,6 +1287,11 @@ expradd:
 | 
			
		||||
  - exadd
 | 
			
		||||
  - exa
 | 
			
		||||
  - acr
 | 
			
		||||
expraddserver:
 | 
			
		||||
  - expradds
 | 
			
		||||
  - exadds
 | 
			
		||||
  - exas
 | 
			
		||||
  - expraddserver
 | 
			
		||||
exprlist:
 | 
			
		||||
  - exprlist
 | 
			
		||||
  - exl
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
# DO NOT CHANGE
 | 
			
		||||
version: 3
 | 
			
		||||
version: 4
 | 
			
		||||
# Most commands, when executed, have a small colored line
 | 
			
		||||
# next to the response. The color depends whether the command
 | 
			
		||||
# is completed, errored or in progress (pending)
 | 
			
		||||
@@ -18,6 +18,8 @@ defaultLocale: en-US
 | 
			
		||||
# Style in which executed commands will show up in the console.
 | 
			
		||||
# Allowed values: Simple, Normal, None
 | 
			
		||||
consoleOutputType: Normal
 | 
			
		||||
# Whether the bot will check for new releases every hour
 | 
			
		||||
checkForUpdates: true
 | 
			
		||||
# Do you want any messages sent by users in Bot's DM to be forwarded to the owner(s)?
 | 
			
		||||
forwardMessages: false
 | 
			
		||||
# Do you want the message to be forwarded only to the first owner specified in the list of owners (in creds.yml),
 | 
			
		||||
 
 | 
			
		||||
@@ -197,7 +197,11 @@ iamnot:
 | 
			
		||||
  args:
 | 
			
		||||
    - "Gamer"
 | 
			
		||||
expradd:
 | 
			
		||||
  desc: "Add an expression with a trigger and a response. Running this command in server requires the Administration permission. Running this command in DM is Bot Owner only and adds a new global expression. Guide here: <https://nadekobot.readthedocs.io/en/latest/custom-reactions/>"
 | 
			
		||||
  desc: "Add an expression with a trigger and a response. Bot will post a response whenever someone types the trigger word.  Running this command in server requires the Administration permission. Running this command in DM is Bot Owner only and adds a new global expression. Guide here: <https://nadekobot.readthedocs.io/en/latest/custom-reactions/>"
 | 
			
		||||
  args:
 | 
			
		||||
    - "\"hello\" Hi there %user.mention%"
 | 
			
		||||
expraddserver:
 | 
			
		||||
  desc: "Add an expression with a trigger and a response in this server. Bot will post a response whenever someone types the trigger word. Guide here: <https://nadekobot.readthedocs.io/en/latest/custom-reactions/>"
 | 
			
		||||
  args:
 | 
			
		||||
    - "\"hello\" Hi there %user.mention%"
 | 
			
		||||
exprlist:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user