Improved support for sql execution, added some pre-built queries which people would probably want to use.
This commit is contained in:
parent
998c048874
commit
e434de5abb
@ -2,12 +2,11 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using NadekoBot.Common.Attributes;
|
using NadekoBot.Common.Attributes;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Modules;
|
|
||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
#if DEBUG
|
#if !GLOBAL_NADEKO
|
||||||
namespace NadekoBot.Modules.Administration
|
namespace NadekoBot.Modules.Administration
|
||||||
{
|
{
|
||||||
public partial class Administration
|
public partial class Administration
|
||||||
@ -42,6 +41,33 @@ namespace NadekoBot.Modules.Administration
|
|||||||
await Context.Channel.SendErrorAsync(ex.ToString());
|
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;");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,6 @@ namespace NadekoBot.Services.Database
|
|||||||
//orphans xD
|
//orphans xD
|
||||||
public DbSet<EightBallResponse> EightBallResponses { get; set; }
|
public DbSet<EightBallResponse> EightBallResponses { get; set; }
|
||||||
public DbSet<RaceAnimal> RaceAnimals { get; set; }
|
public DbSet<RaceAnimal> RaceAnimals { get; set; }
|
||||||
public DbSet<ModulePrefix> ModulePrefixes { get; set; }
|
|
||||||
public DbSet<RewardedUser> RewardedUsers { get; set; }
|
public DbSet<RewardedUser> RewardedUsers { get; set; }
|
||||||
|
|
||||||
public NadekoContext(DbContextOptions<NadekoContext> options) : base(options)
|
public NadekoContext(DbContextOptions<NadekoContext> options) : base(options)
|
||||||
|
@ -132,8 +132,6 @@ namespace NadekoBot
|
|||||||
|
|
||||||
IBotConfigProvider botConfigProvider = new BotConfigProvider(_db, _botConfig);
|
IBotConfigProvider botConfigProvider = new BotConfigProvider(_db, _botConfig);
|
||||||
|
|
||||||
//var localization = new Localization(_botConfig.Locale, AllGuildConfigs.ToDictionary(x => x.GuildId, x => x.Locale), Db);
|
|
||||||
|
|
||||||
//initialize Services
|
//initialize Services
|
||||||
Services = new NServiceProvider()
|
Services = new NServiceProvider()
|
||||||
.AddManual<IBotCredentials>(Credentials)
|
.AddManual<IBotCredentials>(Credentials)
|
||||||
@ -175,9 +173,7 @@ namespace NadekoBot
|
|||||||
var toReturn = new List<object>();
|
var toReturn = new List<object>();
|
||||||
foreach (var ft in filteredTypes)
|
foreach (var ft in filteredTypes)
|
||||||
{
|
{
|
||||||
//:yayyy:
|
|
||||||
var x = (TypeReader)Activator.CreateInstance(ft, Client, CommandService);
|
var x = (TypeReader)Activator.CreateInstance(ft, Client, CommandService);
|
||||||
//@.@ XD XDDD
|
|
||||||
var baseType = ft.BaseType;
|
var baseType = ft.BaseType;
|
||||||
var typeArgs = baseType.GetGenericArguments();
|
var typeArgs = baseType.GetGenericArguments();
|
||||||
try
|
try
|
||||||
|
@ -11,10 +11,6 @@ using NadekoBot.Common;
|
|||||||
using NadekoBot.Common.Attributes;
|
using NadekoBot.Common.Attributes;
|
||||||
using NadekoBot.Modules.Gambling.Services;
|
using NadekoBot.Modules.Gambling.Services;
|
||||||
|
|
||||||
//todo add .deletewaifus
|
|
||||||
//todo add .deletecurrency
|
|
||||||
//todo add .deleteplaylists
|
|
||||||
//todo add .deletexp
|
|
||||||
namespace NadekoBot.Modules.Gambling
|
namespace NadekoBot.Modules.Gambling
|
||||||
{
|
{
|
||||||
public partial class Gambling
|
public partial class Gambling
|
||||||
|
@ -3002,5 +3002,40 @@
|
|||||||
"usage": [
|
"usage": [
|
||||||
"{0}say hi"
|
"{0}say hi"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"execsql": {
|
||||||
|
"cmd": "execsql",
|
||||||
|
"desc": "Executes an sql command and returns the number of affected rows. Dangerous.",
|
||||||
|
"usage": [
|
||||||
|
"{0}execsql UPDATE Currency SET Amount=Amount+1234"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"deletewaifus": {
|
||||||
|
"cmd": "deletewaifus",
|
||||||
|
"desc": "Deletes everything from WaifuUpdates and WaifuInfo tables.",
|
||||||
|
"usage": [
|
||||||
|
"{0}deletewaifus"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"deletecurrency": {
|
||||||
|
"cmd": "deletecurrency",
|
||||||
|
"desc": "Deletes everything from Currency and CurrencyTransactions.",
|
||||||
|
"usage": [
|
||||||
|
"{0}deletecurrency"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"deleteplaylists": {
|
||||||
|
"cmd": "deleteplaylists",
|
||||||
|
"desc": "Deletes everything from MusicPlaylists.",
|
||||||
|
"usage": [
|
||||||
|
"{0}deleteplaylists"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"deletexp": {
|
||||||
|
"cmd": "deletexp",
|
||||||
|
"desc": "Deletes everything from UserXpStats, Clubs and sets users' TotalXP to 0.",
|
||||||
|
"usage": [
|
||||||
|
"{0}execsql UPDATE Currency SET Amount=Amount+1234"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user