From 8107a80c4c835786a955fb5d23b4e2b5352ebc56 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 9 Sep 2022 21:02:16 +0200 Subject: [PATCH] Added .exds to complement .exas --- CHANGELOG.md | 6 +++++ .../CustomReactions/NadekoExpressions.cs | 27 +++++++++++++------ src/NadekoBot/data/aliases.yml | 4 +++ .../data/strings/commands/commands.en-US.yml | 8 ++++-- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dd4f9c82..33596fd13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o +## Unreleased + +### Added + +- Added `.exprdelserv` (.exds) to completement .exas. Deletes an expression on the current server and is susceptible to .dpo, unlike .exd + ## [4.3.6] - 08.09.2022 ### Added diff --git a/src/NadekoBot/Modules/CustomReactions/NadekoExpressions.cs b/src/NadekoBot/Modules/CustomReactions/NadekoExpressions.cs index 518e809c2..827f69e43 100644 --- a/src/NadekoBot/Modules/CustomReactions/NadekoExpressions.cs +++ b/src/NadekoBot/Modules/CustomReactions/NadekoExpressions.cs @@ -160,15 +160,8 @@ public partial class NadekoExpressions : NadekoModule found.Response.TrimTo(1000).Replace("](", "]\\("))); } - [Cmd] - public async Task ExprDelete(kwum id) + public async Task ExprDeleteInternalAsync(kwum id) { - if (!AdminInGuildOrOwnerInDm()) - { - await ReplyErrorLocalizedAsync(strs.expr_insuff_perms); - return; - } - var ex = await _service.DeleteAsync(ctx.Guild?.Id, id); if (ex is not null) @@ -186,6 +179,24 @@ public partial class NadekoExpressions : NadekoModule } } + [Cmd] + [UserPerm(GuildPerm.Administrator)] + [RequireContext(ContextType.Guild)] + public async Task ExprDeleteServer(kwum id) + => await ExprDeleteInternalAsync(id); + + [Cmd] + public async Task ExprDelete(kwum id) + { + if (!AdminInGuildOrOwnerInDm()) + { + await ReplyErrorLocalizedAsync(strs.expr_insuff_perms); + return; + } + + await ExprDeleteInternalAsync(id); + } + [Cmd] public async Task ExprReact(kwum id, params string[] emojiStrs) { diff --git a/src/NadekoBot/data/aliases.yml b/src/NadekoBot/data/aliases.yml index 639eed75e..37054bb96 100644 --- a/src/NadekoBot/data/aliases.yml +++ b/src/NadekoBot/data/aliases.yml @@ -1309,6 +1309,10 @@ exprdelete: - exd - exdel - dcr +exprdeleteserver: + - exprdelserv + - exds + - exdelserv exprclear: - exprclear - exc diff --git a/src/NadekoBot/data/strings/commands/commands.en-US.yml b/src/NadekoBot/data/strings/commands/commands.en-US.yml index 20af429ed..6ab61d206 100644 --- a/src/NadekoBot/data/strings/commands/commands.en-US.yml +++ b/src/NadekoBot/data/strings/commands/commands.en-US.yml @@ -217,13 +217,17 @@ exprlist: - "1" - "all" exprshow: - desc: "Shows a expression's response on a given ID." + desc: "Shows an expression's response on a given ID." args: - "1" exprdelete: - desc: "Deletes a expression on a specific index. If ran in DM, it is bot owner only and deletes a global expression. If ran in a server, it requires Administration privileges and removes server expression." + desc: "Deletes an expression on a specific index. If ran in DM, it is bot owner only and deletes a global expression. If ran in a server, it requires Administration privileges and removes server expression." args: - "5" +exprdeleteserver: + desc: "Deletes an expression on a specific index on this server." + args: + - "5c" exprclear: desc: "Deletes all expression on this server." args: