2017-10-13 00:21:39 +00:00
|
|
|
|
using Discord.Commands;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using NadekoBot.Common.Attributes;
|
|
|
|
|
using NadekoBot.Extensions;
|
2017-10-13 04:14:54 +00:00
|
|
|
|
using NadekoBot.Core.Services;
|
2017-10-13 00:21:39 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
2017-11-03 07:40:43 +00:00
|
|
|
|
using Discord;
|
2017-10-13 00:21:39 +00:00
|
|
|
|
|
2017-10-13 02:41:01 +00:00
|
|
|
|
#if !GLOBAL_NADEKO
|
2017-10-13 00:21:39 +00:00
|
|
|
|
namespace NadekoBot.Modules.Administration
|
|
|
|
|
{
|
2017-10-21 17:48:05 +00:00
|
|
|
|
//todo make users confirm their decision
|
2017-10-13 00:21:39 +00:00
|
|
|
|
public partial class Administration
|
|
|
|
|
{
|
|
|
|
|
[Group]
|
|
|
|
|
[OwnerOnly]
|
|
|
|
|
public class DangerousCommands : NadekoSubmodule
|
|
|
|
|
{
|
|
|
|
|
private readonly DbService _db;
|
|
|
|
|
|
|
|
|
|
public DangerousCommands(DbService db)
|
|
|
|
|
{
|
|
|
|
|
_db = db;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[NadekoCommand, Usage, Description, Aliases]
|
|
|
|
|
[OwnerOnly]
|
|
|
|
|
public async Task ExecSql([Remainder]string sql)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-11-03 07:40:43 +00:00
|
|
|
|
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();
|
|
|
|
|
|
2017-10-13 00:21:39 +00:00
|
|
|
|
int res;
|
|
|
|
|
using (var uow = _db.UnitOfWork)
|
|
|
|
|
{
|
|
|
|
|
res = uow._context.Database.ExecuteSqlCommand(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await Context.Channel.SendConfirmAsync(res.ToString());
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
await Context.Channel.SendErrorAsync(ex.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-10-13 02:41:01 +00:00
|
|
|
|
|
|
|
|
|
[NadekoCommand, Usage, Description, Aliases]
|
|
|
|
|
[OwnerOnly]
|
|
|
|
|
public Task DeleteWaifus() =>
|
2017-10-21 19:06:07 +00:00
|
|
|
|
ExecSql(@"DELETE FROM WaifuUpdates;
|
|
|
|
|
DELETE FROM WaifuItem;
|
|
|
|
|
DELETE FROM WaifuInfo;");
|
2017-10-13 02:41:01 +00:00
|
|
|
|
|
|
|
|
|
[NadekoCommand, Usage, Description, Aliases]
|
|
|
|
|
[OwnerOnly]
|
|
|
|
|
public Task DeleteCurrency() =>
|
|
|
|
|
ExecSql("DELETE FROM Currency; DELETE FROM CurrencyTransactions;");
|
|
|
|
|
|
|
|
|
|
[NadekoCommand, Usage, Description, Aliases]
|
|
|
|
|
[OwnerOnly]
|
|
|
|
|
public Task DeletePlaylists() =>
|
|
|
|
|
ExecSql("DELETE FROM MusicPlaylists;");
|
|
|
|
|
|
|
|
|
|
[NadekoCommand, Usage, Description, Aliases]
|
|
|
|
|
[OwnerOnly]
|
|
|
|
|
public Task DeleteExp() =>
|
|
|
|
|
ExecSql(@"DELETE FROM UserXpStats;
|
|
|
|
|
UPDATE DiscordUser
|
|
|
|
|
SET ClubId=NULL,
|
|
|
|
|
IsClubAdmin=0,
|
|
|
|
|
TotalXp=0;
|
|
|
|
|
DELETE FROM ClubApplicants;
|
|
|
|
|
DELETE FROM ClubBans;
|
|
|
|
|
DELETE FROM Clubs;");
|
2017-10-13 00:21:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|