Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
05ef845ed4 | |||
f4d5be0684 | |||
a7ca860607 | |||
dad789f6f5 | |||
f7eea8732f | |||
ffb7226cb8 | |||
741ba48c23 | |||
a46e6e5a96 | |||
60b736149f | |||
38f149c1e5 | |||
d1166c06a0 | |||
65bcda21c1 | |||
40ee70cd7e | |||
e9948009d9 |
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,10 +1,5 @@
|
|||||||
#Manually added files
|
#Manually added files
|
||||||
|
|
||||||
patreon_rewards.json
|
|
||||||
command_errors*.txt
|
|
||||||
|
|
||||||
src/NadekoBot/Command Errors*.txt
|
|
||||||
|
|
||||||
src/NadekoBot/credentials.json
|
src/NadekoBot/credentials.json
|
||||||
src/NadekoBot/data/NadekoBot.db
|
src/NadekoBot/data/NadekoBot.db
|
||||||
src/NadekoBot/data/musicdata
|
src/NadekoBot/data/musicdata
|
||||||
|
4
.gitmodules
vendored
Normal file
4
.gitmodules
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[submodule "Discord.Net"]
|
||||||
|
path = Discord.Net
|
||||||
|
url = https://github.com/Kwoth/Discord.Net
|
||||||
|
branch = rogue-dev
|
28
.vscode/launch.json
vendored
28
.vscode/launch.json
vendored
@ -1,28 +0,0 @@
|
|||||||
{
|
|
||||||
// Use IntelliSense to find out which attributes exist for C# debugging
|
|
||||||
// Use hover for the description of the existing attributes
|
|
||||||
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": ".NET Core Launch (console)",
|
|
||||||
"type": "coreclr",
|
|
||||||
"request": "launch",
|
|
||||||
"preLaunchTask": "build",
|
|
||||||
// If you have changed target frameworks, make sure to update the program path.
|
|
||||||
"program": "${workspaceRoot}/src/NadekoBot/bin/Debug/netcoreapp1.0/NadekoBot.dll",
|
|
||||||
"args": [],
|
|
||||||
"cwd": "${workspaceRoot}/src/NadekoBot",
|
|
||||||
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
|
|
||||||
"console": "internalConsole",
|
|
||||||
"stopAtEntry": false,
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": ".NET Core Attach",
|
|
||||||
"type": "coreclr",
|
|
||||||
"request": "attach",
|
|
||||||
"processId": "${command:pickProcess}"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
16
.vscode/tasks.json
vendored
16
.vscode/tasks.json
vendored
@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "0.1.0",
|
|
||||||
"command": "dotnet",
|
|
||||||
"isShellCommand": true,
|
|
||||||
"args": [],
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"taskName": "build",
|
|
||||||
"args": [
|
|
||||||
"${workspaceRoot}/src/NadekoBot/project.json"
|
|
||||||
],
|
|
||||||
"isBuildCommand": true,
|
|
||||||
"problemMatcher": "$msCompile"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
1
Discord.Net
Submodule
1
Discord.Net
Submodule
Submodule Discord.Net added at d2229228b9
@ -1,13 +0,0 @@
|
|||||||
using System.Linq;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using Discord.Commands;
|
|
||||||
using NadekoBot.Core.Services.Impl;
|
|
||||||
namespace NadekoBot.Common.Attributes
|
|
||||||
{
|
|
||||||
public class Aliases : AliasAttribute
|
|
||||||
{
|
|
||||||
public Aliases([CallerMemberName] string memberName = "") : base(Localization.LoadCommand(memberName.ToLowerInvariant()).Cmd.Split(' ').Skip(1).ToArray())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System.Runtime.CompilerServices;
|
|
||||||
using Discord.Commands;
|
|
||||||
using NadekoBot.Core.Services.Impl;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.Attributes
|
|
||||||
{
|
|
||||||
public class Description : SummaryAttribute
|
|
||||||
{
|
|
||||||
public Description([CallerMemberName] string memberName="") : base(Localization.LoadCommand(memberName.ToLowerInvariant()).Desc)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System.Runtime.CompilerServices;
|
|
||||||
using Discord.Commands;
|
|
||||||
using NadekoBot.Core.Services.Impl;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.Attributes
|
|
||||||
{
|
|
||||||
public class NadekoCommand : CommandAttribute
|
|
||||||
{
|
|
||||||
public NadekoCommand([CallerMemberName] string memberName="") : base(Localization.LoadCommand(memberName.ToLowerInvariant()).Cmd.Split(' ')[0])
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Discord.Commands;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.Attributes
|
|
||||||
{
|
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
|
||||||
sealed class NadekoModuleAttribute : GroupAttribute
|
|
||||||
{
|
|
||||||
public NadekoModuleAttribute(string moduleName) : base(moduleName)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.Attributes
|
|
||||||
{
|
|
||||||
public class NadekoOptions : Attribute
|
|
||||||
{
|
|
||||||
public Type OptionType { get; set; }
|
|
||||||
|
|
||||||
public NadekoOptions(Type t)
|
|
||||||
{
|
|
||||||
this.OptionType = t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Discord.Commands;
|
|
||||||
using NadekoBot.Core.Services;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.Attributes
|
|
||||||
{
|
|
||||||
public class OwnerOnlyAttribute : PreconditionAttribute
|
|
||||||
{
|
|
||||||
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo executingCommand, IServiceProvider services)
|
|
||||||
{
|
|
||||||
var creds = (IBotCredentials)services.GetService(typeof(IBotCredentials));
|
|
||||||
|
|
||||||
return Task.FromResult((creds.IsOwner(context.User) || context.Client.CurrentUser.Id == context.User.Id ? PreconditionResult.FromSuccess() : PreconditionResult.FromError("Not owner")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
using System.Runtime.CompilerServices;
|
|
||||||
using Discord.Commands;
|
|
||||||
using NadekoBot.Core.Services.Impl;
|
|
||||||
using System.Linq;
|
|
||||||
using Discord;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.Attributes
|
|
||||||
{
|
|
||||||
public class Usage : RemarksAttribute
|
|
||||||
{
|
|
||||||
public Usage([CallerMemberName] string memberName="") : base(Usage.GetUsage(memberName))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetUsage(string memberName)
|
|
||||||
{
|
|
||||||
var usage = Localization.LoadCommand(memberName.ToLowerInvariant()).Usage;
|
|
||||||
return string.Join(" or ", usage
|
|
||||||
.Select(x => Format.Code(x)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
namespace NadekoBot.Common
|
|
||||||
{
|
|
||||||
public enum BotConfigEditType
|
|
||||||
{
|
|
||||||
BetflipMultiplier,
|
|
||||||
Betroll100Multiplier,
|
|
||||||
Betroll67Multiplier,
|
|
||||||
Betroll91Multiplier,
|
|
||||||
CurrencyGenerationChance,
|
|
||||||
CurrencyGenerationCooldown,
|
|
||||||
CurrencyName,
|
|
||||||
CurrencyPluralName,
|
|
||||||
CurrencySign,
|
|
||||||
DmHelpString,
|
|
||||||
HelpString,
|
|
||||||
CurrencyDropAmount,
|
|
||||||
CurrencyDropAmountMax,
|
|
||||||
MinimumBetAmount,
|
|
||||||
TriviaCurrencyReward,
|
|
||||||
XpPerMessage,
|
|
||||||
XpMinutesTimeout,
|
|
||||||
|
|
||||||
//ErrorColor, //after i fix the nadekobot.cs static variables
|
|
||||||
//OkColor
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace NadekoBot.Core.Common.Caching
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A caching object which loads its value with a factory method when it expires.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">Type of the value which is cached.</typeparam>
|
|
||||||
public class FactoryCache<T> : IFactoryCache
|
|
||||||
{
|
|
||||||
public DateTime LastUpdate { get; set; } = DateTime.MinValue;
|
|
||||||
private readonly object _locker = new object();
|
|
||||||
private TimeSpan _expireAfter;
|
|
||||||
private readonly Func<T> _factory;
|
|
||||||
private T Value;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new factory cache object.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="factory">Method which loads the value when it expires or if it's not loaded the first time.</param>
|
|
||||||
/// <param name="expireAfter">Time after which the value will be reloaded.</param>
|
|
||||||
/// <param name="loadImmediately">Should the value be loaded right away. If set to false, value will load when it's first retrieved.</param>
|
|
||||||
public FactoryCache(Func<T> factory, TimeSpan expireAfter,
|
|
||||||
bool loadImmediately = false)
|
|
||||||
{
|
|
||||||
_expireAfter = expireAfter;
|
|
||||||
_factory = factory;
|
|
||||||
if (loadImmediately)
|
|
||||||
{
|
|
||||||
Value = _factory();
|
|
||||||
LastUpdate = DateTime.UtcNow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public T GetValue()
|
|
||||||
{
|
|
||||||
lock (_locker)
|
|
||||||
{
|
|
||||||
if (DateTime.UtcNow - LastUpdate > _expireAfter)
|
|
||||||
{
|
|
||||||
LastUpdate = DateTime.UtcNow;
|
|
||||||
return Value = _factory();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace NadekoBot.Core.Common.Caching
|
|
||||||
{
|
|
||||||
public interface IFactoryCache
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,106 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.Collections
|
|
||||||
{
|
|
||||||
public class PoopyRingBuffer : IDisposable
|
|
||||||
{
|
|
||||||
// readpos == writepos means empty
|
|
||||||
// writepos == readpos - 1 means full
|
|
||||||
|
|
||||||
private byte[] _buffer;
|
|
||||||
public int Capacity { get; }
|
|
||||||
|
|
||||||
private int ReadPos { get; set; } = 0;
|
|
||||||
private int WritePos { get; set; } = 0;
|
|
||||||
|
|
||||||
public int Length => ReadPos <= WritePos
|
|
||||||
? WritePos - ReadPos
|
|
||||||
: Capacity - (ReadPos - WritePos);
|
|
||||||
|
|
||||||
public int RemainingCapacity
|
|
||||||
{
|
|
||||||
get => Capacity - Length - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly SemaphoreSlim _locker = new SemaphoreSlim(1, 1);
|
|
||||||
|
|
||||||
public PoopyRingBuffer(int capacity = 81920 * 100)
|
|
||||||
{
|
|
||||||
this.Capacity = capacity + 1;
|
|
||||||
this._buffer = new byte[this.Capacity];
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Read(byte[] b, int offset, int toRead)
|
|
||||||
{
|
|
||||||
if (WritePos == ReadPos)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (toRead > Length)
|
|
||||||
toRead = Length;
|
|
||||||
|
|
||||||
if (WritePos > ReadPos)
|
|
||||||
{
|
|
||||||
Array.Copy(_buffer, ReadPos, b, offset, toRead);
|
|
||||||
ReadPos += toRead;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var toEnd = Capacity - ReadPos;
|
|
||||||
var firstRead = toRead > toEnd ?
|
|
||||||
toEnd :
|
|
||||||
toRead;
|
|
||||||
Array.Copy(_buffer, ReadPos, b, offset, firstRead);
|
|
||||||
ReadPos += firstRead;
|
|
||||||
var secondRead = toRead - firstRead;
|
|
||||||
if (secondRead > 0)
|
|
||||||
{
|
|
||||||
Array.Copy(_buffer, 0, b, offset + firstRead, secondRead);
|
|
||||||
ReadPos = secondRead;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return toRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Write(byte[] b, int offset, int toWrite)
|
|
||||||
{
|
|
||||||
while (toWrite > RemainingCapacity)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (toWrite == 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (WritePos < ReadPos)
|
|
||||||
{
|
|
||||||
Array.Copy(b, offset, _buffer, WritePos, toWrite);
|
|
||||||
WritePos += toWrite;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var toEnd = Capacity - WritePos;
|
|
||||||
var firstWrite = toWrite > toEnd ?
|
|
||||||
toEnd :
|
|
||||||
toWrite;
|
|
||||||
Array.Copy(b, offset, _buffer, WritePos, firstWrite);
|
|
||||||
var secondWrite = toWrite - firstWrite;
|
|
||||||
if (secondWrite > 0)
|
|
||||||
{
|
|
||||||
Array.Copy(b, offset + firstWrite, _buffer, 0, secondWrite);
|
|
||||||
WritePos = secondWrite;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WritePos += firstWrite;
|
|
||||||
if (WritePos == Capacity)
|
|
||||||
WritePos = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
_buffer = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
namespace NadekoBot.Common
|
|
||||||
{
|
|
||||||
public class CommandData
|
|
||||||
{
|
|
||||||
public string Cmd { get; set; }
|
|
||||||
public string Desc { get; set; }
|
|
||||||
public string[] Usage { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace NadekoBot.Core.Common
|
|
||||||
{
|
|
||||||
public interface INadekoCommandOptions
|
|
||||||
{
|
|
||||||
void NormalizeOptions();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using System.Threading.Tasks;
|
|
||||||
using Discord;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.ModuleBehaviors
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Implemented by modules which block execution before anything is executed
|
|
||||||
/// </summary>
|
|
||||||
public interface IEarlyBlocker
|
|
||||||
{
|
|
||||||
Task<bool> TryBlockEarly(IGuild guild, IUserMessage msg);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
using System.Threading.Tasks;
|
|
||||||
using Discord;
|
|
||||||
using Discord.WebSocket;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.ModuleBehaviors
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Implemented by modules which can execute something and prevent further commands from being executed.
|
|
||||||
/// </summary>
|
|
||||||
public interface IEarlyBlockingExecutor
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Try to execute some logic within some module's service.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Whether it should block other command executions after it.</returns>
|
|
||||||
Task<bool> TryExecuteEarly(DiscordSocketClient client, IGuild guild, IUserMessage msg);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
namespace NadekoBot.Common.ModuleBehaviors
|
|
||||||
{
|
|
||||||
public interface IEarlyExecutor
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
using System.Threading.Tasks;
|
|
||||||
using Discord;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.ModuleBehaviors
|
|
||||||
{
|
|
||||||
public interface IInputTransformer
|
|
||||||
{
|
|
||||||
Task<string> TransformInput(IGuild guild, IMessageChannel channel, IUser user, string input);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
using System.Threading.Tasks;
|
|
||||||
using Discord;
|
|
||||||
using Discord.WebSocket;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.ModuleBehaviors
|
|
||||||
{
|
|
||||||
public interface ILateBlocker
|
|
||||||
{
|
|
||||||
Task<bool> TryBlockLate(DiscordSocketClient client, IUserMessage msg, IGuild guild,
|
|
||||||
IMessageChannel channel, IUser user, string moduleName, string commandName);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
namespace NadekoBot.Common.ModuleBehaviors
|
|
||||||
{
|
|
||||||
public interface ILateBlockingExecutor
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
using System.Threading.Tasks;
|
|
||||||
using Discord;
|
|
||||||
using Discord.WebSocket;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.ModuleBehaviors
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Last thing to be executed, won't stop further executions
|
|
||||||
/// </summary>
|
|
||||||
public interface ILateExecutor
|
|
||||||
{
|
|
||||||
Task LateExecute(DiscordSocketClient client, IGuild guild, IUserMessage msg);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
namespace NadekoBot.Modules
|
|
||||||
{
|
|
||||||
public static class NadekoModuleExtensions
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Discord.Commands;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common
|
|
||||||
{
|
|
||||||
public class NoPublicBot : PreconditionAttribute
|
|
||||||
{
|
|
||||||
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
|
|
||||||
{
|
|
||||||
#if GLOBAL_NADEKo
|
|
||||||
return Task.FromResult(PreconditionResult.FromError("Not available on the public bot"));
|
|
||||||
#else
|
|
||||||
return Task.FromResult(PreconditionResult.FromSuccess());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using CommandLine;
|
|
||||||
|
|
||||||
namespace NadekoBot.Core.Common
|
|
||||||
{
|
|
||||||
public class OptionsParser
|
|
||||||
{
|
|
||||||
private static OptionsParser _instance = new OptionsParser();
|
|
||||||
public static OptionsParser Default => _instance;
|
|
||||||
|
|
||||||
static OptionsParser() { }
|
|
||||||
|
|
||||||
public T ParseFrom<T>(T options, string[] args) where T : INadekoCommandOptions
|
|
||||||
{
|
|
||||||
var res = Parser.Default.ParseArguments<T>(args);
|
|
||||||
options = (T)res.MapResult(x => x, x => options);
|
|
||||||
options.NormalizeOptions();
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
namespace NadekoBot.Core.Common.Pokemon
|
|
||||||
{
|
|
||||||
public class PokemonNameId
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
namespace NadekoBot.Core.Common.Pokemon
|
|
||||||
{
|
|
||||||
public class SearchPokemonAbility
|
|
||||||
{
|
|
||||||
public string Desc { get; set; }
|
|
||||||
public string ShortDesc { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public float Rating { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,147 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using Discord;
|
|
||||||
using Discord.Commands;
|
|
||||||
using Discord.WebSocket;
|
|
||||||
using NadekoBot.Extensions;
|
|
||||||
using NadekoBot.Modules.Music.Services;
|
|
||||||
using NadekoBot.Modules.Administration.Services;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.Replacements
|
|
||||||
{
|
|
||||||
public class ReplacementBuilder
|
|
||||||
{
|
|
||||||
private static readonly Regex rngRegex = new Regex("%rng(?:(?<from>(?:-)?\\d+)-(?<to>(?:-)?\\d+))?%", RegexOptions.Compiled);
|
|
||||||
private ConcurrentDictionary<string, Func<string>> _reps = new ConcurrentDictionary<string, Func<string>>();
|
|
||||||
private ConcurrentDictionary<Regex, Func<Match, string>> _regex = new ConcurrentDictionary<Regex, Func<Match, string>>();
|
|
||||||
|
|
||||||
public ReplacementBuilder()
|
|
||||||
{
|
|
||||||
WithRngRegex();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReplacementBuilder WithDefault(IUser usr, IMessageChannel ch, IGuild g, DiscordSocketClient client)
|
|
||||||
{
|
|
||||||
return this.WithUser(usr)
|
|
||||||
.WithChannel(ch)
|
|
||||||
.WithServer(client, g)
|
|
||||||
.WithClient(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReplacementBuilder WithDefault(ICommandContext ctx) =>
|
|
||||||
WithDefault(ctx.User, ctx.Channel, ctx.Guild, (DiscordSocketClient)ctx.Client);
|
|
||||||
|
|
||||||
public ReplacementBuilder WithClient(DiscordSocketClient client)
|
|
||||||
{
|
|
||||||
_reps.TryAdd("%mention%", () => $"<@{client.CurrentUser.Id}>");
|
|
||||||
_reps.TryAdd("%shardid%", () => client.ShardId.ToString());
|
|
||||||
_reps.TryAdd("%time%", () => DateTime.Now.ToString("HH:mm " + TimeZoneInfo.Local.StandardName.GetInitials()));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReplacementBuilder WithServer(DiscordSocketClient client, IGuild g)
|
|
||||||
{
|
|
||||||
|
|
||||||
_reps.TryAdd("%sid%", () => g == null ? "DM" : g.Id.ToString());
|
|
||||||
_reps.TryAdd("%server%", () => g == null ? "DM" : g.Name);
|
|
||||||
_reps.TryAdd("%server_time%", () =>
|
|
||||||
{
|
|
||||||
TimeZoneInfo to = TimeZoneInfo.Local;
|
|
||||||
if (g != null)
|
|
||||||
{
|
|
||||||
if (GuildTimezoneService.AllServices.TryGetValue(client.CurrentUser.Id, out var tz))
|
|
||||||
to = tz.GetTimeZoneOrDefault(g.Id) ?? TimeZoneInfo.Local;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TimeZoneInfo.ConvertTime(DateTime.UtcNow,
|
|
||||||
TimeZoneInfo.Utc,
|
|
||||||
to).ToString("HH:mm ") + to.StandardName.GetInitials();
|
|
||||||
});
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReplacementBuilder WithChannel(IMessageChannel ch)
|
|
||||||
{
|
|
||||||
_reps.TryAdd("%channel%", () => (ch as ITextChannel)?.Mention ?? "#" + ch.Name);
|
|
||||||
_reps.TryAdd("%chname%", () => ch.Name);
|
|
||||||
_reps.TryAdd("%cid%", () => ch?.Id.ToString());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReplacementBuilder WithUser(IUser user)
|
|
||||||
{
|
|
||||||
_reps.TryAdd("%user%", () => user.Mention);
|
|
||||||
_reps.TryAdd("%userfull%", () => user.ToString());
|
|
||||||
_reps.TryAdd("%username%", () => user.Username);
|
|
||||||
_reps.TryAdd("%userdiscrim%", () => user.Discriminator);
|
|
||||||
_reps.TryAdd("%id%", () => user.Id.ToString());
|
|
||||||
_reps.TryAdd("%uid%", () => user.Id.ToString());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReplacementBuilder WithStats(DiscordSocketClient c)
|
|
||||||
{
|
|
||||||
_reps.TryAdd("%servers%", () => c.Guilds.Count.ToString());
|
|
||||||
_reps.TryAdd("%users%", () => c.Guilds.Sum(s => s.Users.Count).ToString());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReplacementBuilder WithMusic(MusicService ms)
|
|
||||||
{
|
|
||||||
_reps.TryAdd("%playing%", () =>
|
|
||||||
{
|
|
||||||
var cnt = ms.MusicPlayers.Count(kvp => kvp.Value.Current.Current != null);
|
|
||||||
if (cnt != 1) return cnt.ToString();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var mp = ms.MusicPlayers.FirstOrDefault();
|
|
||||||
var title = mp.Value?.Current.Current?.Title;
|
|
||||||
return title ?? "No songs";
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return "error";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
_reps.TryAdd("%queued%", () => ms.MusicPlayers.Sum(kvp => kvp.Value.QueueArray().Songs.Length).ToString());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReplacementBuilder WithRngRegex()
|
|
||||||
{
|
|
||||||
var rng = new NadekoRandom();
|
|
||||||
_regex.TryAdd(rngRegex, (match) =>
|
|
||||||
{
|
|
||||||
int from = 0;
|
|
||||||
int.TryParse(match.Groups["from"].ToString(), out from);
|
|
||||||
|
|
||||||
int to = 0;
|
|
||||||
int.TryParse(match.Groups["to"].ToString(), out to);
|
|
||||||
|
|
||||||
if (from == 0 && to == 0)
|
|
||||||
{
|
|
||||||
return rng.Next(0, 11).ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (from >= to)
|
|
||||||
return string.Empty;
|
|
||||||
|
|
||||||
return rng.Next(from, to + 1).ToString();
|
|
||||||
});
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReplacementBuilder WithOverride(string key, Func<string> output)
|
|
||||||
{
|
|
||||||
_reps.AddOrUpdate(key, output, delegate { return output; });
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Replacer Build()
|
|
||||||
{
|
|
||||||
return new Replacer(_reps.Select(x => (x.Key, x.Value)).ToArray(), _regex.Select(x => (x.Key, x.Value)).ToArray());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.Replacements
|
|
||||||
{
|
|
||||||
public class Replacer
|
|
||||||
{
|
|
||||||
private readonly IEnumerable<(string Key, Func<string> Text)> _replacements;
|
|
||||||
private readonly IEnumerable<(Regex Regex, Func<Match, string> Replacement)> _regex;
|
|
||||||
|
|
||||||
public Replacer(IEnumerable<(string, Func<string>)> replacements, IEnumerable<(Regex, Func<Match, string>)> regex)
|
|
||||||
{
|
|
||||||
_replacements = replacements;
|
|
||||||
_regex = regex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Replace(string input)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(input))
|
|
||||||
return input;
|
|
||||||
|
|
||||||
foreach (var item in _replacements)
|
|
||||||
{
|
|
||||||
if (input.Contains(item.Key))
|
|
||||||
input = input.Replace(item.Key, item.Text());
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in _regex)
|
|
||||||
{
|
|
||||||
input = item.Regex.Replace(input, (m) => item.Replacement(m));
|
|
||||||
}
|
|
||||||
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Replace(CREmbed embedData)
|
|
||||||
{
|
|
||||||
embedData.PlainText = Replace(embedData.PlainText);
|
|
||||||
embedData.Description = Replace(embedData.Description);
|
|
||||||
embedData.Title = Replace(embedData.Title);
|
|
||||||
|
|
||||||
if (embedData.Fields != null)
|
|
||||||
foreach (var f in embedData.Fields)
|
|
||||||
{
|
|
||||||
f.Name = Replace(f.Name);
|
|
||||||
f.Value = Replace(f.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (embedData.Footer != null)
|
|
||||||
embedData.Footer.Text = Replace(embedData.Footer.Text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Discord;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.ShardCom
|
|
||||||
{
|
|
||||||
public class ShardComMessage
|
|
||||||
{
|
|
||||||
public int ShardId { get; set; }
|
|
||||||
public ConnectionState ConnectionState { get; set; }
|
|
||||||
public int Guilds { get; set; }
|
|
||||||
public DateTime Time { get; set; }
|
|
||||||
|
|
||||||
public ShardComMessage Clone() =>
|
|
||||||
new ShardComMessage
|
|
||||||
{
|
|
||||||
ShardId = ShardId,
|
|
||||||
ConnectionState = ConnectionState,
|
|
||||||
Guilds = Guilds,
|
|
||||||
Time = Time,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Net;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using NadekoBot.Core.Services;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.ShardCom
|
|
||||||
{
|
|
||||||
public class ShardComServer
|
|
||||||
{
|
|
||||||
private readonly IDataCache _cache;
|
|
||||||
|
|
||||||
public ShardComServer(IDataCache cache)
|
|
||||||
{
|
|
||||||
_cache = cache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Start()
|
|
||||||
{
|
|
||||||
var sub = _cache.Redis.GetSubscriber();
|
|
||||||
sub.SubscribeAsync("shardcoord_send", (ch, data) =>
|
|
||||||
{
|
|
||||||
var _ = OnDataReceived(JsonConvert.DeserializeObject<ShardComMessage>(data));
|
|
||||||
}, StackExchange.Redis.CommandFlags.FireAndForget);
|
|
||||||
}
|
|
||||||
|
|
||||||
public event Func<ShardComMessage, Task> OnDataReceived = delegate { return Task.CompletedTask; };
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,91 +0,0 @@
|
|||||||
using Discord;
|
|
||||||
using Discord.WebSocket;
|
|
||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common
|
|
||||||
{
|
|
||||||
public class ReactionEventWrapper : IDisposable
|
|
||||||
{
|
|
||||||
public IUserMessage Message { get; }
|
|
||||||
public event Action<SocketReaction> OnReactionAdded = delegate { };
|
|
||||||
public event Action<SocketReaction> OnReactionRemoved = delegate { };
|
|
||||||
public event Action OnReactionsCleared = delegate { };
|
|
||||||
|
|
||||||
public ReactionEventWrapper(DiscordSocketClient client, IUserMessage msg)
|
|
||||||
{
|
|
||||||
Message = msg ?? throw new ArgumentNullException(nameof(msg));
|
|
||||||
_client = client;
|
|
||||||
|
|
||||||
_client.ReactionAdded += Discord_ReactionAdded;
|
|
||||||
_client.ReactionRemoved += Discord_ReactionRemoved;
|
|
||||||
_client.ReactionsCleared += Discord_ReactionsCleared;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Task Discord_ReactionsCleared(Cacheable<IUserMessage, ulong> msg, ISocketMessageChannel channel)
|
|
||||||
{
|
|
||||||
Task.Run(() =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (msg.Id == Message.Id)
|
|
||||||
OnReactionsCleared?.Invoke();
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
});
|
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Task Discord_ReactionRemoved(Cacheable<IUserMessage, ulong> msg, ISocketMessageChannel channel, SocketReaction reaction)
|
|
||||||
{
|
|
||||||
Task.Run(() =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (msg.Id == Message.Id)
|
|
||||||
OnReactionRemoved?.Invoke(reaction);
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
});
|
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Task Discord_ReactionAdded(Cacheable<IUserMessage, ulong> msg, ISocketMessageChannel channel, SocketReaction reaction)
|
|
||||||
{
|
|
||||||
Task.Run(() =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (msg.Id == Message.Id)
|
|
||||||
OnReactionAdded?.Invoke(reaction);
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
});
|
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UnsubAll()
|
|
||||||
{
|
|
||||||
_client.ReactionAdded -= Discord_ReactionAdded;
|
|
||||||
_client.ReactionRemoved -= Discord_ReactionRemoved;
|
|
||||||
_client.ReactionsCleared -= Discord_ReactionsCleared;
|
|
||||||
OnReactionAdded = null;
|
|
||||||
OnReactionRemoved = null;
|
|
||||||
OnReactionsCleared = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool disposing = false;
|
|
||||||
private readonly DiscordSocketClient _client;
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
if (disposing)
|
|
||||||
return;
|
|
||||||
disposing = true;
|
|
||||||
UnsubAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
namespace NadekoBot.Common.TypeReaders
|
|
||||||
{
|
|
||||||
public enum AddRemove
|
|
||||||
{
|
|
||||||
Add = 0,
|
|
||||||
Rem = 1,
|
|
||||||
Rm = 1,
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,88 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Discord.Commands;
|
|
||||||
using NadekoBot.Core.Services;
|
|
||||||
using NadekoBot.Modules.CustomReactions.Services;
|
|
||||||
using NadekoBot.Core.Common.TypeReaders;
|
|
||||||
using Discord.WebSocket;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.TypeReaders
|
|
||||||
{
|
|
||||||
public class CommandTypeReader : NadekoTypeReader<CommandInfo>
|
|
||||||
{
|
|
||||||
public CommandTypeReader(DiscordSocketClient client, CommandService cmds) : base(client, cmds)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Task<TypeReaderResult> ReadAsync(ICommandContext context, string input, IServiceProvider services)
|
|
||||||
{
|
|
||||||
var _cmds = ((INServiceProvider)services).GetService<CommandService>();
|
|
||||||
var _cmdHandler = ((INServiceProvider)services).GetService<CommandHandler>();
|
|
||||||
input = input.ToUpperInvariant();
|
|
||||||
var prefix = _cmdHandler.GetPrefix(context.Guild);
|
|
||||||
if (!input.StartsWith(prefix.ToUpperInvariant()))
|
|
||||||
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "No such command found."));
|
|
||||||
|
|
||||||
input = input.Substring(prefix.Length);
|
|
||||||
|
|
||||||
var cmd = _cmds.Commands.FirstOrDefault(c =>
|
|
||||||
c.Aliases.Select(a => a.ToUpperInvariant()).Contains(input));
|
|
||||||
if (cmd == null)
|
|
||||||
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "No such command found."));
|
|
||||||
|
|
||||||
return Task.FromResult(TypeReaderResult.FromSuccess(cmd));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CommandOrCrTypeReader : NadekoTypeReader<CommandOrCrInfo>
|
|
||||||
{
|
|
||||||
private readonly DiscordSocketClient _client;
|
|
||||||
private readonly CommandService _cmds;
|
|
||||||
public CommandOrCrTypeReader(DiscordSocketClient client, CommandService cmds) : base(client, cmds)
|
|
||||||
{
|
|
||||||
_client = client;
|
|
||||||
_cmds = cmds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async Task<TypeReaderResult> ReadAsync(ICommandContext context, string input, IServiceProvider services)
|
|
||||||
{
|
|
||||||
input = input.ToUpperInvariant();
|
|
||||||
|
|
||||||
var _crs = ((INServiceProvider)services).GetService<CustomReactionsService>();
|
|
||||||
|
|
||||||
if (_crs.GlobalReactions.Any(x => x.Trigger.ToUpperInvariant() == input))
|
|
||||||
{
|
|
||||||
return TypeReaderResult.FromSuccess(new CommandOrCrInfo(input));
|
|
||||||
}
|
|
||||||
var guild = context.Guild;
|
|
||||||
if (guild != null)
|
|
||||||
{
|
|
||||||
if (_crs.GuildReactions.TryGetValue(guild.Id, out var crs))
|
|
||||||
{
|
|
||||||
if (crs.Concat(_crs.GlobalReactions).Any(x => x.Trigger.ToUpperInvariant() == input))
|
|
||||||
{
|
|
||||||
return TypeReaderResult.FromSuccess(new CommandOrCrInfo(input));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var cmd = await new CommandTypeReader(_client, _cmds).ReadAsync(context, input, services);
|
|
||||||
if (cmd.IsSuccess)
|
|
||||||
{
|
|
||||||
return TypeReaderResult.FromSuccess(new CommandOrCrInfo(((CommandInfo)cmd.Values.First().Value).Name));
|
|
||||||
}
|
|
||||||
return TypeReaderResult.FromError(CommandError.ParseFailed, "No such command or cr found.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CommandOrCrInfo
|
|
||||||
{
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
public CommandOrCrInfo(string input)
|
|
||||||
{
|
|
||||||
this.Name = input;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Discord.Commands;
|
|
||||||
using NadekoBot.Modules.Administration.Services;
|
|
||||||
using NadekoBot.Core.Common.TypeReaders;
|
|
||||||
using Discord.WebSocket;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.TypeReaders
|
|
||||||
{
|
|
||||||
public class GuildDateTimeTypeReader : NadekoTypeReader<GuildDateTime>
|
|
||||||
{
|
|
||||||
public GuildDateTimeTypeReader(DiscordSocketClient client, CommandService cmds) : base(client, cmds)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Task<TypeReaderResult> ReadAsync(ICommandContext context, string input, IServiceProvider services)
|
|
||||||
{
|
|
||||||
var _gts = (GuildTimezoneService)services.GetService(typeof(GuildTimezoneService));
|
|
||||||
if (!DateTime.TryParse(input, out var dt))
|
|
||||||
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "Input string is in an incorrect format."));
|
|
||||||
|
|
||||||
var tz = _gts.GetTimeZoneOrUtc(context.Guild.Id);
|
|
||||||
|
|
||||||
return Task.FromResult(TypeReaderResult.FromSuccess(new GuildDateTime(tz, dt)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class GuildDateTime
|
|
||||||
{
|
|
||||||
public TimeZoneInfo Timezone { get; }
|
|
||||||
public DateTime CurrentGuildTime { get; }
|
|
||||||
public DateTime InputTime { get; }
|
|
||||||
public DateTime InputTimeUtc { get; }
|
|
||||||
|
|
||||||
private GuildDateTime() { }
|
|
||||||
|
|
||||||
public GuildDateTime(TimeZoneInfo guildTimezone, DateTime inputTime)
|
|
||||||
{
|
|
||||||
var now = DateTime.UtcNow;
|
|
||||||
Timezone = guildTimezone;
|
|
||||||
CurrentGuildTime = TimeZoneInfo.ConvertTime(now, TimeZoneInfo.Utc, Timezone);
|
|
||||||
InputTime = inputTime;
|
|
||||||
InputTimeUtc = TimeZoneInfo.ConvertTime(inputTime, Timezone, TimeZoneInfo.Utc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Discord.Commands;
|
|
||||||
using NadekoBot.Extensions;
|
|
||||||
using NadekoBot.Core.Common.TypeReaders;
|
|
||||||
using Discord.WebSocket;
|
|
||||||
|
|
||||||
namespace NadekoBot.Common.TypeReaders
|
|
||||||
{
|
|
||||||
public class ModuleTypeReader : NadekoTypeReader<ModuleInfo>
|
|
||||||
{
|
|
||||||
private readonly CommandService _cmds;
|
|
||||||
|
|
||||||
public ModuleTypeReader(DiscordSocketClient client, CommandService cmds) : base(client, cmds)
|
|
||||||
{
|
|
||||||
_cmds = cmds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Task<TypeReaderResult> ReadAsync(ICommandContext context, string input, IServiceProvider _)
|
|
||||||
{
|
|
||||||
input = input.ToUpperInvariant();
|
|
||||||
var module = _cmds.Modules.GroupBy(m => m.GetTopLevelModule()).FirstOrDefault(m => m.Key.Name.ToUpperInvariant() == input)?.Key;
|
|
||||||
if (module == null)
|
|
||||||
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "No such module found."));
|
|
||||||
|
|
||||||
return Task.FromResult(TypeReaderResult.FromSuccess(module));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ModuleOrCrTypeReader : NadekoTypeReader<ModuleOrCrInfo>
|
|
||||||
{
|
|
||||||
private readonly CommandService _cmds;
|
|
||||||
|
|
||||||
public ModuleOrCrTypeReader(DiscordSocketClient client, CommandService cmds) : base(client, cmds)
|
|
||||||
{
|
|
||||||
_cmds = cmds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Task<TypeReaderResult> ReadAsync(ICommandContext context, string input, IServiceProvider _)
|
|
||||||
{
|
|
||||||
input = input.ToLowerInvariant();
|
|
||||||
var module = _cmds.Modules.GroupBy(m => m.GetTopLevelModule()).FirstOrDefault(m => m.Key.Name.ToLowerInvariant() == input)?.Key;
|
|
||||||
if (module == null && input != "actualcustomreactions")
|
|
||||||
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "No such module found."));
|
|
||||||
|
|
||||||
return Task.FromResult(TypeReaderResult.FromSuccess(new ModuleOrCrInfo
|
|
||||||
{
|
|
||||||
Name = input,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ModuleOrCrInfo
|
|
||||||
{
|
|
||||||
public string Name { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
using Discord.Commands;
|
|
||||||
using Discord.WebSocket;
|
|
||||||
|
|
||||||
namespace NadekoBot.Core.Common.TypeReaders
|
|
||||||
{
|
|
||||||
public abstract class NadekoTypeReader<T> : TypeReader where
|
|
||||||
T : class
|
|
||||||
{
|
|
||||||
private readonly DiscordSocketClient _client;
|
|
||||||
private readonly CommandService _cmds;
|
|
||||||
|
|
||||||
private NadekoTypeReader() { }
|
|
||||||
public NadekoTypeReader(DiscordSocketClient client, CommandService cmds)
|
|
||||||
{
|
|
||||||
_client = client;
|
|
||||||
_cmds = cmds;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class permissionsversion : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "PermissionVersion",
|
|
||||||
table: "BotConfig",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "PermissionVersion",
|
|
||||||
table: "BotConfig");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,32 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class guildprefixes : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "Prefix",
|
|
||||||
table: "GuildConfigs",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "DefaultPrefix",
|
|
||||||
table: "BotConfig",
|
|
||||||
nullable: true,
|
|
||||||
defaultValue: ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Prefix",
|
|
||||||
table: "GuildConfigs");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "DefaultPrefix",
|
|
||||||
table: "BotConfig");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,23 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class verboseerrors : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<bool>(
|
|
||||||
name: "VerboseErrors",
|
|
||||||
table: "GuildConfigs",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "VerboseErrors",
|
|
||||||
table: "GuildConfigs");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class repeattimeofday : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<TimeSpan>(
|
|
||||||
name: "StartTimeOfDay",
|
|
||||||
table: "GuildRepeater",
|
|
||||||
nullable: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "StartTimeOfDay",
|
|
||||||
table: "GuildRepeater");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,22 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class maxdropamount : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "CurrencyDropAmountMax",
|
|
||||||
table: "BotConfig",
|
|
||||||
nullable: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "CurrencyDropAmountMax",
|
|
||||||
table: "BotConfig");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,23 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class crstartswith : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<bool>(
|
|
||||||
name: "CustomReactionsStartWith",
|
|
||||||
table: "BotConfig",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "CustomReactionsStartWith",
|
|
||||||
table: "BotConfig");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,45 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class streamrole : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "StreamRoleSettings",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
AddRoleId = table.Column<ulong>(nullable: false),
|
|
||||||
DateAdded = table.Column<DateTime>(nullable: true),
|
|
||||||
FromRoleId = table.Column<ulong>(nullable: false),
|
|
||||||
GuildConfigId = table.Column<int>(nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_StreamRoleSettings", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_StreamRoleSettings_GuildConfigs_GuildConfigId",
|
|
||||||
column: x => x.GuildConfigId,
|
|
||||||
principalTable: "GuildConfigs",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_StreamRoleSettings_GuildConfigId",
|
|
||||||
table: "StreamRoleSettings",
|
|
||||||
column: "GuildConfigId",
|
|
||||||
unique: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "StreamRoleSettings");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,93 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class streamrolekwblwl : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<bool>(
|
|
||||||
name: "Enabled",
|
|
||||||
table: "StreamRoleSettings",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: false);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "Keyword",
|
|
||||||
table: "StreamRoleSettings",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "StreamRoleBlacklistedUser",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
DateAdded = table.Column<DateTime>(nullable: true),
|
|
||||||
StreamRoleSettingsId = table.Column<int>(nullable: true),
|
|
||||||
UserId = table.Column<ulong>(nullable: false),
|
|
||||||
Username = table.Column<string>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_StreamRoleBlacklistedUser", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_StreamRoleBlacklistedUser_StreamRoleSettings_StreamRoleSettingsId",
|
|
||||||
column: x => x.StreamRoleSettingsId,
|
|
||||||
principalTable: "StreamRoleSettings",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "StreamRoleWhitelistedUser",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
DateAdded = table.Column<DateTime>(nullable: true),
|
|
||||||
StreamRoleSettingsId = table.Column<int>(nullable: true),
|
|
||||||
UserId = table.Column<ulong>(nullable: false),
|
|
||||||
Username = table.Column<string>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_StreamRoleWhitelistedUser", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_StreamRoleWhitelistedUser_StreamRoleSettings_StreamRoleSettingsId",
|
|
||||||
column: x => x.StreamRoleSettingsId,
|
|
||||||
principalTable: "StreamRoleSettings",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_StreamRoleBlacklistedUser_StreamRoleSettingsId",
|
|
||||||
table: "StreamRoleBlacklistedUser",
|
|
||||||
column: "StreamRoleSettingsId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_StreamRoleWhitelistedUser_StreamRoleSettingsId",
|
|
||||||
table: "StreamRoleWhitelistedUser",
|
|
||||||
column: "StreamRoleSettingsId");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "StreamRoleBlacklistedUser");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "StreamRoleWhitelistedUser");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Enabled",
|
|
||||||
table: "StreamRoleSettings");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Keyword",
|
|
||||||
table: "StreamRoleSettings");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,44 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class nsfwblacklist : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "NsfwBlacklitedTag",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
DateAdded = table.Column<DateTime>(nullable: true),
|
|
||||||
GuildConfigId = table.Column<int>(nullable: true),
|
|
||||||
Tag = table.Column<string>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_NsfwBlacklitedTag", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_NsfwBlacklitedTag_GuildConfigs_GuildConfigId",
|
|
||||||
column: x => x.GuildConfigId,
|
|
||||||
principalTable: "GuildConfigs",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_NsfwBlacklitedTag_GuildConfigId",
|
|
||||||
table: "NsfwBlacklitedTag",
|
|
||||||
column: "GuildConfigId");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "NsfwBlacklitedTag");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
1682
NadekoBot.Core/Migrations/20170722074959_cr-ca.Designer.cs
generated
1682
NadekoBot.Core/Migrations/20170722074959_cr-ca.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -1,25 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class crca : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<bool>(
|
|
||||||
name: "ContainsAnywhere",
|
|
||||||
table: "CustomReactions",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "ContainsAnywhere",
|
|
||||||
table: "CustomReactions");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,46 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class waifuitems : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "WaifuItem",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
DateAdded = table.Column<DateTime>(nullable: true),
|
|
||||||
Item = table.Column<int>(nullable: false),
|
|
||||||
ItemEmoji = table.Column<string>(nullable: true),
|
|
||||||
Price = table.Column<int>(nullable: false),
|
|
||||||
WaifuInfoId = table.Column<int>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_WaifuItem", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_WaifuItem_WaifuInfo_WaifuInfoId",
|
|
||||||
column: x => x.WaifuInfoId,
|
|
||||||
principalTable: "WaifuInfo",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_WaifuItem_WaifuInfoId",
|
|
||||||
table: "WaifuItem",
|
|
||||||
column: "WaifuInfoId");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "WaifuItem");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,25 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class mutetimeantispam : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "MuteTime",
|
|
||||||
table: "AntiSpamSetting",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "MuteTime",
|
|
||||||
table: "AntiSpamSetting");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,296 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class xpandclubs : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "XpMinutesTimeout",
|
|
||||||
table: "BotConfig",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 5)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "XpPerMessage",
|
|
||||||
table: "BotConfig",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 3)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Clubs",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
DateAdded = table.Column<DateTime>(nullable: true),
|
|
||||||
Discrim = table.Column<int>(nullable: false),
|
|
||||||
ImageUrl = table.Column<string>(nullable: true),
|
|
||||||
MinimumLevelReq = table.Column<int>(nullable: false),
|
|
||||||
Name = table.Column<string>(maxLength: 20, nullable: false),
|
|
||||||
OwnerId = table.Column<int>(nullable: false),
|
|
||||||
Xp = table.Column<int>(nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Clubs", x => x.Id);
|
|
||||||
table.UniqueConstraint("AK_Clubs_Name_Discrim", x => new { x.Name, x.Discrim });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Clubs_DiscordUser_OwnerId",
|
|
||||||
column: x => x.OwnerId,
|
|
||||||
principalTable: "DiscordUser",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.Sql(MigrationQueries.UserClub);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<DateTime>(
|
|
||||||
name: "LastLevelUp",
|
|
||||||
table: "DiscordUser",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: DateTime.UtcNow);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "NotifyOnLevelUp",
|
|
||||||
table: "DiscordUser",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "UserXpStats",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
AwardedXp = table.Column<int>(nullable: false),
|
|
||||||
DateAdded = table.Column<DateTime>(nullable: true),
|
|
||||||
GuildId = table.Column<ulong>(nullable: false),
|
|
||||||
LastLevelUp = table.Column<DateTime>(nullable: false, defaultValue: new DateTime(2017, 9, 9, 1, 7, 29, 858, DateTimeKind.Local)),
|
|
||||||
NotifyOnLevelUp = table.Column<int>(nullable: false),
|
|
||||||
UserId = table.Column<ulong>(nullable: false),
|
|
||||||
Xp = table.Column<int>(nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_UserXpStats", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "XpSettings",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
DateAdded = table.Column<DateTime>(nullable: true),
|
|
||||||
GuildConfigId = table.Column<int>(nullable: false),
|
|
||||||
NotifyMessage = table.Column<string>(nullable: true),
|
|
||||||
ServerExcluded = table.Column<bool>(nullable: false),
|
|
||||||
XpRoleRewardExclusive = table.Column<bool>(nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_XpSettings", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_XpSettings_GuildConfigs_GuildConfigId",
|
|
||||||
column: x => x.GuildConfigId,
|
|
||||||
principalTable: "GuildConfigs",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "ClubApplicants",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ClubId = table.Column<int>(nullable: false),
|
|
||||||
UserId = table.Column<int>(nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_ClubApplicants", x => new { x.ClubId, x.UserId });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_ClubApplicants_Clubs_ClubId",
|
|
||||||
column: x => x.ClubId,
|
|
||||||
principalTable: "Clubs",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_ClubApplicants_DiscordUser_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "DiscordUser",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "ClubBans",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ClubId = table.Column<int>(nullable: false),
|
|
||||||
UserId = table.Column<int>(nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_ClubBans", x => new { x.ClubId, x.UserId });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_ClubBans_Clubs_ClubId",
|
|
||||||
column: x => x.ClubId,
|
|
||||||
principalTable: "Clubs",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_ClubBans_DiscordUser_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "DiscordUser",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "ExcludedItem",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
DateAdded = table.Column<DateTime>(nullable: true),
|
|
||||||
ItemId = table.Column<ulong>(nullable: false),
|
|
||||||
ItemType = table.Column<int>(nullable: false),
|
|
||||||
XpSettingsId = table.Column<int>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_ExcludedItem", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_ExcludedItem_XpSettings_XpSettingsId",
|
|
||||||
column: x => x.XpSettingsId,
|
|
||||||
principalTable: "XpSettings",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "XpRoleReward",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
DateAdded = table.Column<DateTime>(nullable: true),
|
|
||||||
Level = table.Column<int>(nullable: false),
|
|
||||||
RoleId = table.Column<ulong>(nullable: false),
|
|
||||||
XpSettingsId = table.Column<int>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_XpRoleReward", x => x.Id);
|
|
||||||
table.UniqueConstraint("AK_XpRoleReward_Level", x => x.Level);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_XpRoleReward_XpSettings_XpSettingsId",
|
|
||||||
column: x => x.XpSettingsId,
|
|
||||||
principalTable: "XpSettings",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_DiscordUser_ClubId",
|
|
||||||
table: "DiscordUser",
|
|
||||||
column: "ClubId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_ClubApplicants_UserId",
|
|
||||||
table: "ClubApplicants",
|
|
||||||
column: "UserId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_ClubBans_UserId",
|
|
||||||
table: "ClubBans",
|
|
||||||
column: "UserId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Clubs_OwnerId",
|
|
||||||
table: "Clubs",
|
|
||||||
column: "OwnerId",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_ExcludedItem_XpSettingsId",
|
|
||||||
table: "ExcludedItem",
|
|
||||||
column: "XpSettingsId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_UserXpStats_UserId_GuildId",
|
|
||||||
table: "UserXpStats",
|
|
||||||
columns: new[] { "UserId", "GuildId" },
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_XpRoleReward_XpSettingsId",
|
|
||||||
table: "XpRoleReward",
|
|
||||||
column: "XpSettingsId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_XpSettings_GuildConfigId",
|
|
||||||
table: "XpSettings",
|
|
||||||
column: "GuildConfigId",
|
|
||||||
unique: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_DiscordUser_Clubs_ClubId",
|
|
||||||
table: "DiscordUser");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ClubApplicants");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ClubBans");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ExcludedItem");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "UserXpStats");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "XpRoleReward");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Clubs");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "XpSettings");
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_DiscordUser_ClubId",
|
|
||||||
table: "DiscordUser");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "ClubId",
|
|
||||||
table: "DiscordUser");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "LastLevelUp",
|
|
||||||
table: "DiscordUser");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "NotifyOnLevelUp",
|
|
||||||
table: "DiscordUser");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "XpMinutesTimeout",
|
|
||||||
table: "BotConfig");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "XpPerMessage",
|
|
||||||
table: "BotConfig");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,27 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class lastXpGain : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<DateTime>(
|
|
||||||
name: "LastXpGain",
|
|
||||||
table: "DiscordUser",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
|
||||||
|
|
||||||
migrationBuilder.Sql("DELETE FROM XpRoleReward WHERE XpSettingsId is null");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "LastXpGain",
|
|
||||||
table: "DiscordUser");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,27 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class totalxp : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "TotalXp",
|
|
||||||
table: "DiscordUser",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
|
|
||||||
migrationBuilder.Sql(MigrationQueries.TotalXp);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "TotalXp",
|
|
||||||
table: "DiscordUser");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,25 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class clubadmins : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<bool>(
|
|
||||||
name: "IsClubAdmin",
|
|
||||||
table: "DiscordUser",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "IsClubAdmin",
|
|
||||||
table: "DiscordUser");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
1985
NadekoBot.Core/Migrations/20170921185313_feeds.Designer.cs
generated
1985
NadekoBot.Core/Migrations/20170921185313_feeds.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -1,59 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class feeds : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "FeedSub",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
|
||||||
DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true),
|
|
||||||
GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
||||||
Url = table.Column<string>(type: "TEXT", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_FeedSub", x => x.Id);
|
|
||||||
table.UniqueConstraint("AK_FeedSub_GuildConfigId_Url", x => new { x.GuildConfigId, x.Url });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_FeedSub_GuildConfigs_GuildConfigId",
|
|
||||||
column: x => x.GuildConfigId,
|
|
||||||
principalTable: "GuildConfigs",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "FeedSub");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<DateTime>(
|
|
||||||
name: "LastLevelUp",
|
|
||||||
table: "UserXpStats",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: new DateTime(2017, 9, 15, 5, 48, 8, 665, DateTimeKind.Local),
|
|
||||||
oldClrType: typeof(DateTime),
|
|
||||||
oldType: "TEXT",
|
|
||||||
oldDefaultValue: new DateTime(2017, 9, 21, 20, 53, 13, 307, DateTimeKind.Local));
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<DateTime>(
|
|
||||||
name: "LastLevelUp",
|
|
||||||
table: "DiscordUser",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: new DateTime(2017, 9, 15, 5, 48, 8, 660, DateTimeKind.Local),
|
|
||||||
oldClrType: typeof(DateTime),
|
|
||||||
oldType: "TEXT",
|
|
||||||
oldDefaultValue: new DateTime(2017, 9, 21, 20, 53, 13, 305, DateTimeKind.Local));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,47 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class xprrfix : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable("XpRoleReward");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "XpRoleReward",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true),
|
|
||||||
Level = table.Column<int>(type: "INTEGER", nullable: false),
|
|
||||||
RoleId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
|
||||||
XpSettingsId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_XpRoleReward", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_XpRoleReward_XpSettings_XpSettingsId",
|
|
||||||
column: x => x.XpSettingsId,
|
|
||||||
principalTable: "XpSettings",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_XpRoleReward_XpSettingsId_Level",
|
|
||||||
table: "XpRoleReward",
|
|
||||||
columns: new[] { "XpSettingsId", "Level" },
|
|
||||||
unique: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,129 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class clearandloadedpackage : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ClashCallers");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ModulePrefixes");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ClashOfClans");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "LoadedPackages",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
BotConfigId = table.Column<int>(type: "INTEGER", nullable: true),
|
|
||||||
DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true),
|
|
||||||
Name = table.Column<string>(type: "TEXT", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_LoadedPackages", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_LoadedPackages_BotConfig_BotConfigId",
|
|
||||||
column: x => x.BotConfigId,
|
|
||||||
principalTable: "BotConfig",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_LoadedPackages_BotConfigId",
|
|
||||||
table: "LoadedPackages",
|
|
||||||
column: "BotConfigId");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "LoadedPackages");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "ClashOfClans",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
ChannelId = table.Column<ulong>(nullable: false),
|
|
||||||
DateAdded = table.Column<DateTime>(nullable: true),
|
|
||||||
EnemyClan = table.Column<string>(nullable: true),
|
|
||||||
GuildId = table.Column<ulong>(nullable: false),
|
|
||||||
Size = table.Column<int>(nullable: false),
|
|
||||||
StartedAt = table.Column<DateTime>(nullable: false),
|
|
||||||
WarState = table.Column<int>(nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_ClashOfClans", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "ModulePrefixes",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
BotConfigId = table.Column<int>(nullable: true),
|
|
||||||
DateAdded = table.Column<DateTime>(nullable: true),
|
|
||||||
ModuleName = table.Column<string>(nullable: true),
|
|
||||||
Prefix = table.Column<string>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_ModulePrefixes", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_ModulePrefixes_BotConfig_BotConfigId",
|
|
||||||
column: x => x.BotConfigId,
|
|
||||||
principalTable: "BotConfig",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "ClashCallers",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
BaseDestroyed = table.Column<bool>(nullable: false),
|
|
||||||
CallUser = table.Column<string>(nullable: true),
|
|
||||||
ClashWarId = table.Column<int>(nullable: false),
|
|
||||||
DateAdded = table.Column<DateTime>(nullable: true),
|
|
||||||
SequenceNumber = table.Column<int>(nullable: true),
|
|
||||||
Stars = table.Column<int>(nullable: false),
|
|
||||||
TimeAdded = table.Column<DateTime>(nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_ClashCallers", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_ClashCallers_ClashOfClans_ClashWarId",
|
|
||||||
column: x => x.ClashWarId,
|
|
||||||
principalTable: "ClashOfClans",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_ClashCallers_ClashWarId",
|
|
||||||
table: "ClashCallers",
|
|
||||||
column: "ClashWarId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_ModulePrefixes_BotConfigId",
|
|
||||||
table: "ModulePrefixes",
|
|
||||||
column: "BotConfigId");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,34 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class removeconvertunits : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ConversionUnits");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "ConversionUnits",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
DateAdded = table.Column<DateTime>(nullable: true),
|
|
||||||
InternalTrigger = table.Column<string>(nullable: true),
|
|
||||||
Modifier = table.Column<decimal>(nullable: false),
|
|
||||||
UnitType = table.Column<string>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_ConversionUnits", x => x.Id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,27 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class tesargrouping : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "Group",
|
|
||||||
table: "SelfAssignableRoles",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Group",
|
|
||||||
table: "SelfAssignableRoles");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,26 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class vcautodc : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<bool>(
|
|
||||||
name: "AutoDcFromVc",
|
|
||||||
table: "GuildConfigs",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "AutoDcFromVc",
|
|
||||||
table: "GuildConfigs");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
1917
NadekoBot.Core/Migrations/20171026090236_timely.Designer.cs
generated
1917
NadekoBot.Core/Migrations/20171026090236_timely.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -1,37 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class timely : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "TimelyCurrency",
|
|
||||||
table: "BotConfig",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "TimelyCurrencyPeriod",
|
|
||||||
table: "BotConfig",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "TimelyCurrency",
|
|
||||||
table: "BotConfig");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "TimelyCurrencyPeriod",
|
|
||||||
table: "BotConfig");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,100 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class pollrewrite : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Poll",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
|
||||||
DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true),
|
|
||||||
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
|
||||||
Question = table.Column<string>(type: "TEXT", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Poll", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "PollAnswer",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true),
|
|
||||||
Index = table.Column<int>(type: "INTEGER", nullable: false),
|
|
||||||
PollId = table.Column<int>(type: "INTEGER", nullable: true),
|
|
||||||
Text = table.Column<string>(type: "TEXT", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_PollAnswer", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_PollAnswer_Poll_PollId",
|
|
||||||
column: x => x.PollId,
|
|
||||||
principalTable: "Poll",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "PollVote",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true),
|
|
||||||
PollId = table.Column<int>(type: "INTEGER", nullable: true),
|
|
||||||
UserId = table.Column<ulong>(type: "INTEGER", nullable: false),
|
|
||||||
VoteIndex = table.Column<int>(type: "INTEGER", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_PollVote", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_PollVote_Poll_PollId",
|
|
||||||
column: x => x.PollId,
|
|
||||||
principalTable: "Poll",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Poll_GuildId",
|
|
||||||
table: "Poll",
|
|
||||||
column: "GuildId",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_PollAnswer_PollId",
|
|
||||||
table: "PollAnswer",
|
|
||||||
column: "PollId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_PollVote_PollId",
|
|
||||||
table: "PollVote",
|
|
||||||
column: "PollId");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "PollAnswer");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "PollVote");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Poll");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,26 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class sarlevelreq : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "LevelRequirement",
|
|
||||||
table: "SelfAssignableRoles",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "LevelRequirement",
|
|
||||||
table: "SelfAssignableRoles");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,45 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class currencylevelupreward : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "XpCurrencyReward",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
Amount = table.Column<int>(type: "INTEGER", nullable: false),
|
|
||||||
DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true),
|
|
||||||
Level = table.Column<int>(type: "INTEGER", nullable: false),
|
|
||||||
XpSettingsId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_XpCurrencyReward", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_XpCurrencyReward_XpSettings_XpSettingsId",
|
|
||||||
column: x => x.XpSettingsId,
|
|
||||||
principalTable: "XpSettings",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_XpCurrencyReward_XpSettingsId",
|
|
||||||
table: "XpCurrencyReward",
|
|
||||||
column: "XpSettingsId");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "XpCurrencyReward");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,46 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
public partial class persistsadandmusicchannel : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "MusicSettings",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true),
|
|
||||||
GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
||||||
MusicChannelId = table.Column<ulong>(type: "INTEGER", nullable: true),
|
|
||||||
SongAutoDelete = table.Column<bool>(type: "INTEGER", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_MusicSettings", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_MusicSettings_GuildConfigs_GuildConfigId",
|
|
||||||
column: x => x.GuildConfigId,
|
|
||||||
principalTable: "GuildConfigs",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_MusicSettings_GuildConfigId",
|
|
||||||
table: "MusicSettings",
|
|
||||||
column: "GuildConfigId",
|
|
||||||
unique: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "MusicSettings");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
namespace NadekoBot.Migrations
|
|
||||||
{
|
|
||||||
internal class MigrationQueries
|
|
||||||
{
|
|
||||||
public static string UserClub { get; } = @"
|
|
||||||
CREATE TABLE DiscordUser_tmp(
|
|
||||||
Id INTEGER PRIMARY KEY,
|
|
||||||
AvatarId TEXT,
|
|
||||||
Discriminator TEXT,
|
|
||||||
UserId INTEGER UNIQUE NOT NULL,
|
|
||||||
DateAdded TEXT,
|
|
||||||
Username TEXT
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT INTO DiscordUser_tmp
|
|
||||||
SELECT Id, AvatarId, Discriminator, UserId, DateAdded, Username
|
|
||||||
FROM DiscordUser;
|
|
||||||
|
|
||||||
DROP TABLE DiscordUser;
|
|
||||||
|
|
||||||
CREATE TABLE DiscordUser(
|
|
||||||
Id INTEGER PRIMARY KEY,
|
|
||||||
AvatarId TEXT,
|
|
||||||
Discriminator TEXT,
|
|
||||||
UserId INTEGER UNIQUE NOT NULL,
|
|
||||||
DateAdded TEXT,
|
|
||||||
Username TEXT,
|
|
||||||
ClubId INTEGER,
|
|
||||||
CONSTRAINT FK_DiscordUser_Clubs_ClubId FOREIGN KEY(ClubId) REFERENCES Clubs(Id) ON DELETE RESTRICT
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT INTO DiscordUser
|
|
||||||
SELECT Id, AvatarId, Discriminator, UserId, DateAdded, Username, NULL
|
|
||||||
FROM DiscordUser_tmp;
|
|
||||||
|
|
||||||
DROP TABLE DiscordUser_tmp;";
|
|
||||||
public static string TotalXp { get; } =
|
|
||||||
@"UPDATE DiscordUser
|
|
||||||
SET TotalXp = ifnull((SELECT SUM(Xp) FROM UserXpStats WHERE UserId = DiscordUser.UserId), 0)";
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,46 +0,0 @@
|
|||||||
using Discord;
|
|
||||||
using Discord.Commands;
|
|
||||||
using NadekoBot.Extensions;
|
|
||||||
using NadekoBot.Core.Services;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using NadekoBot.Common.Attributes;
|
|
||||||
using NadekoBot.Modules.Administration.Services;
|
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration
|
|
||||||
{
|
|
||||||
public partial class Administration
|
|
||||||
{
|
|
||||||
[Group]
|
|
||||||
public class AutoAssignRoleCommands : NadekoSubmodule<AutoAssignRoleService>
|
|
||||||
{
|
|
||||||
private readonly DbService _db;
|
|
||||||
|
|
||||||
public AutoAssignRoleCommands(DbService db)
|
|
||||||
{
|
|
||||||
_db = db;
|
|
||||||
}
|
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
|
||||||
[RequireContext(ContextType.Guild)]
|
|
||||||
[RequireUserPermission(GuildPermission.ManageRoles)]
|
|
||||||
public async Task AutoAssignRole([Remainder] IRole role = null)
|
|
||||||
{
|
|
||||||
var guser = (IGuildUser)Context.User;
|
|
||||||
if (role != null)
|
|
||||||
if (Context.User.Id != guser.Guild.OwnerId && guser.GetRoles().Max(x => x.Position) <= role.Position)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (role == null)
|
|
||||||
{
|
|
||||||
_service.DisableAar(Context.Guild.Id);
|
|
||||||
await ReplyConfirmLocalized("aar_disabled").ConfigureAwait(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_service.EnableAar(Context.Guild.Id, role.Id);
|
|
||||||
await ReplyConfirmLocalized("aar_enabled").ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
using System.Collections.Concurrent;
|
|
||||||
using Discord;
|
|
||||||
using NadekoBot.Common.Collections;
|
|
||||||
using NadekoBot.Core.Services.Database.Models;
|
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Common
|
|
||||||
{
|
|
||||||
public enum ProtectionType
|
|
||||||
{
|
|
||||||
Raiding,
|
|
||||||
Spamming,
|
|
||||||
}
|
|
||||||
|
|
||||||
public class AntiRaidStats
|
|
||||||
{
|
|
||||||
public AntiRaidSetting AntiRaidSettings { get; set; }
|
|
||||||
public int UsersCount { get; set; }
|
|
||||||
public ConcurrentHashSet<IGuildUser> RaidUsers { get; set; } = new ConcurrentHashSet<IGuildUser>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class AntiSpamStats
|
|
||||||
{
|
|
||||||
public AntiSpamSetting AntiSpamSettings { get; set; }
|
|
||||||
public ConcurrentDictionary<ulong, UserSpamStats> UserStats { get; set; }
|
|
||||||
= new ConcurrentDictionary<ulong, UserSpamStats>();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Discord.WebSocket;
|
|
||||||
using NadekoBot.Modules.Administration.Services;
|
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Common
|
|
||||||
{
|
|
||||||
public class Ratelimiter
|
|
||||||
{
|
|
||||||
private readonly SlowmodeService _svc;
|
|
||||||
|
|
||||||
public class RatelimitedUser
|
|
||||||
{
|
|
||||||
public ulong UserId { get; set; }
|
|
||||||
public int MessageCount { get; set; } = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ulong ChannelId { get; set; }
|
|
||||||
public int MaxMessages { get; set; }
|
|
||||||
public int PerSeconds { get; set; }
|
|
||||||
|
|
||||||
public Ratelimiter(SlowmodeService svc)
|
|
||||||
{
|
|
||||||
_svc = svc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CancellationTokenSource CancelSource { get; set; } = new CancellationTokenSource();
|
|
||||||
|
|
||||||
public ConcurrentDictionary<ulong, RatelimitedUser> Users { get; set; } = new ConcurrentDictionary<ulong, RatelimitedUser>();
|
|
||||||
|
|
||||||
public bool CheckUserRatelimit(ulong id, ulong guildId, SocketGuildUser optUser)
|
|
||||||
{
|
|
||||||
if ((_svc.IgnoredUsers.TryGetValue(guildId, out HashSet<ulong> ignoreUsers) && ignoreUsers.Contains(id)) ||
|
|
||||||
(optUser != null && _svc.IgnoredRoles.TryGetValue(guildId, out HashSet<ulong> ignoreRoles) && optUser.Roles.Any(x => ignoreRoles.Contains(x.Id))))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var usr = Users.GetOrAdd(id, (key) => new RatelimitedUser() { UserId = id });
|
|
||||||
if (usr.MessageCount >= MaxMessages)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
usr.MessageCount++;
|
|
||||||
var _ = Task.Run(async () =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await Task.Delay(PerSeconds * 1000, CancelSource.Token);
|
|
||||||
}
|
|
||||||
catch (OperationCanceledException) { }
|
|
||||||
usr.MessageCount--;
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using Discord;
|
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Common
|
|
||||||
{
|
|
||||||
public class UserSpamStats : IDisposable
|
|
||||||
{
|
|
||||||
public int Count => timers.Count;
|
|
||||||
public string LastMessage { get; set; }
|
|
||||||
|
|
||||||
private ConcurrentQueue<Timer> timers { get; }
|
|
||||||
|
|
||||||
public UserSpamStats(IUserMessage msg)
|
|
||||||
{
|
|
||||||
LastMessage = msg.Content.ToUpperInvariant();
|
|
||||||
timers = new ConcurrentQueue<Timer>();
|
|
||||||
|
|
||||||
ApplyNextMessage(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly object applyLock = new object();
|
|
||||||
public void ApplyNextMessage(IUserMessage message)
|
|
||||||
{
|
|
||||||
lock (applyLock)
|
|
||||||
{
|
|
||||||
var upperMsg = message.Content.ToUpperInvariant();
|
|
||||||
if (upperMsg != LastMessage || (string.IsNullOrWhiteSpace(upperMsg) && message.Attachments.Any()))
|
|
||||||
{
|
|
||||||
LastMessage = upperMsg;
|
|
||||||
while (timers.TryDequeue(out var old))
|
|
||||||
old.Change(Timeout.Infinite, Timeout.Infinite);
|
|
||||||
}
|
|
||||||
var t = new Timer((_) => {
|
|
||||||
if (timers.TryDequeue(out var old))
|
|
||||||
old.Change(Timeout.Infinite, Timeout.Infinite);
|
|
||||||
}, null, TimeSpan.FromMinutes(30), TimeSpan.FromMinutes(30));
|
|
||||||
timers.Enqueue(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
while (timers.TryDequeue(out var old))
|
|
||||||
old.Change(Timeout.Infinite, Timeout.Infinite);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,92 +0,0 @@
|
|||||||
using Discord.Commands;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using NadekoBot.Common.Attributes;
|
|
||||||
using NadekoBot.Extensions;
|
|
||||||
using NadekoBot.Core.Services;
|
|
||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Discord;
|
|
||||||
|
|
||||||
#if !GLOBAL_NADEKO
|
|
||||||
namespace NadekoBot.Modules.Administration
|
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
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 WaifuItem;
|
|
||||||
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
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user