From 9b0f6993d5f3be53ef374f947a831a5a7d6d485a Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Fri, 3 Nov 2017 08:40:43 +0100 Subject: [PATCH] Executing sql command requires confirmation now since it can mess up things really badly if user doens't know what they're doing. --- .../Modules/Administration/DangerousCommands.cs | 16 ++++++++++++++++ .../_strings/ResponseStrings.en-US.json | 1 + 2 files changed, 17 insertions(+) diff --git a/NadekoBot.Core/Modules/Administration/DangerousCommands.cs b/NadekoBot.Core/Modules/Administration/DangerousCommands.cs index c0889c0e..e1649495 100644 --- a/NadekoBot.Core/Modules/Administration/DangerousCommands.cs +++ b/NadekoBot.Core/Modules/Administration/DangerousCommands.cs @@ -5,6 +5,7 @@ using NadekoBot.Extensions; using NadekoBot.Core.Services; using System; using System.Threading.Tasks; +using Discord; #if !GLOBAL_NADEKO namespace NadekoBot.Modules.Administration @@ -29,6 +30,21 @@ namespace NadekoBot.Modules.Administration { try { + var msg = await Context.Channel.EmbedAsync(new EmbedBuilder() + .WithOkColor() + .WithTitle(GetText("sql_confirm_exec")) + .WithDescription(Format.Code(sql)) + .WithFooter("yes/no")).ConfigureAwait(false); + + var input = await GetUserInputAsync(Context.User.Id, Context.Channel.Id); + input = input?.ToLowerInvariant().ToString(); + + if (input != "yes" && input != "y") + { + return; + } + var _ = msg.DeleteAsync(); + int res; using (var uow = _db.UnitOfWork) { diff --git a/src/NadekoBot/_strings/ResponseStrings.en-US.json b/src/NadekoBot/_strings/ResponseStrings.en-US.json index c1740228..e8e862fb 100644 --- a/src/NadekoBot/_strings/ResponseStrings.en-US.json +++ b/src/NadekoBot/_strings/ResponseStrings.en-US.json @@ -662,6 +662,7 @@ "games_pick_sn": "Pick it up by typing `{0}pick`", "gambling_no_users_found": "No user found.", "gambling_page": "page {0}", + "administration_sql_confirm_exec": "Confirm execution of the following SQL command", "administration_must_be_in_voice": "You must be in a voice channel on this server.", "administration_no_vcroles": "There are no voice channel roles.", "administration_user_muted_time": "{0} has been **muted** from text and voice chat for {1} minutes.",