NadekoBot/NadekoBot.Core/Modules/Administration/DangerousCommands.cs
2017-10-21 19:48:05 +02:00

75 lines
2.1 KiB
C#

using Discord.Commands;
using Microsoft.EntityFrameworkCore;
using NadekoBot.Common.Attributes;
using NadekoBot.Extensions;
using NadekoBot.Core.Services;
using System;
using System.Threading.Tasks;
#if !GLOBAL_NADEKO
namespace NadekoBot.Modules.Administration
{
//todo make users confirm their decision
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
{
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());
}
}
[NadekoCommand, Usage, Description, Aliases]
[OwnerOnly]
public Task DeleteWaifus() =>
ExecSql("DELETE FROM WaifuUpdates; DELETE FROM WaifuInfo;");
[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;");
}
}
}
#endif