- Removed NadekoCommand and Aliases attribute from all commands

- All commands must be marked as partial
- Added [Cmd] Attribute to all commands
- Cmd Attribute comes from the source generator which adds [NadekoCommand] and [Aliases] Attribute to each command
- Should be updated in the future probably to be more performant and maybe add extra data to the commands
- Started reorganizing modules and submodules
This commit is contained in:
Kwoth
2021-12-31 16:04:12 +01:00
parent 6eee161b6b
commit 25eeffa163
107 changed files with 1620 additions and 3236 deletions

View File

@@ -0,0 +1,343 @@
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
namespace NadekoBot.Generators.Command;
[Generator]
public class CommandAttributesGenerator : IIncrementalGenerator
{
public const string ATTRIBUTE = @"// <AutoGenerated />
namespace NadekoBot.Common;
[System.AttributeUsage(System.AttributeTargets.Method)]
public class CmdAttribute : System.Attribute
{
}";
public class MethodModel
{
public string Namespace { get; set; }
public IReadOnlyCollection<string> Classes { get; set; }
public string ReturnType { get; set; }
public string MethodName { get; set; }
public IEnumerable<string> Params { get; set; }
}
public class FileModel
{
public string Namespace { get; set; }
public IReadOnlyCollection<string> ClassHierarchy { get; set; }
public IReadOnlyCollection<MethodModel> Methods { get; set; }
}
public void Initialize(IncrementalGeneratorInitializationContext context)
{
context.RegisterPostInitializationOutput(static ctx => ctx.AddSource(
"CmdAttribute.g.cs",
SourceText.From(ATTRIBUTE, Encoding.UTF8)));
var methods = context.SyntaxProvider
.CreateSyntaxProvider(
static (node, _) => node is MethodDeclarationSyntax { AttributeLists.Count: > 0 },
static (ctx, cancel) => Transform(ctx, cancel))
.Where(static m => m != default)
.Where(static m => m.ChildTokens().Any(static x => x.IsKind(SyntaxKind.PublicKeyword)));
var compilationMethods = context.CompilationProvider.Combine(methods.Collect());
context.RegisterSourceOutput(compilationMethods,
static (ctx, tuple) => RegisterAction(in ctx, tuple.Left, in tuple.Right));
}
private static void RegisterAction(in SourceProductionContext ctx,
Compilation comp,
in ImmutableArray<MethodDeclarationSyntax> methods)
{
if (methods.IsDefaultOrEmpty)
return;
var models = GetModels(comp, methods, ctx.CancellationToken);
foreach (var model in models)
{
var source = GetSourceText(model);
ctx.AddSource($"{model.Namespace}.{string.Join(".", model.ClassHierarchy)}.g.cs",
SourceText.From(source, Encoding.UTF8));
}
}
// private static void GenerateFileFromModel(in SourceProductionContext ctx, IGrouping<string, DataModel> @group)
// {
// using var sw = new StringWriter();
// using var tw = new IndentedTextWriter(sw);
//
// foreach (var model in group)
// {
// tw.WriteLine($"public partial {model.ReturnType} {model.MethodName}({string.Join(", ", model.Params)});");
// }
//
// GenerateFileFromModel(ctx, sw.ToString(), group.Key, group.AsEnumerable());
//
//
// }
// private static void GenerateFileFromModel(SourceProductionContext ctx, string innerContent, string groupName, IEnumerable<DataModel> modelsEnum)
// {
// using var sw = new StringWriter();
// using var tw = new IndentedTextWriter(sw);
//
// var models = modelsEnum.ToList();
// var referenceModel = models.First();
// tw.WriteLine($"namespace {referenceModel.Namespace};");
//
// foreach (var className in referenceModel.ClassNames.Reverse().ToList())
// {
// tw.WriteLine($"public partial class {className}");
// tw.WriteLine("{");
// tw.WriteLine();
// tw.Indent ++;
// }
//
// foreach (var model in models)
// {
// tw.WriteLine($"public partial {model.ReturnType} {model.MethodName}({string.Join(", ", model.Params)});");
// }
//
// foreach (var _ in referenceModel.ClassNames)
// {
// tw.Indent --;
// tw.WriteLine("}");
// }
//
// // tw.Indent--;
// // tw.WriteLine("}");
// tw.Flush();
//
// ctx.AddSource($"{groupName}.qwertyus.g.cs",
// SourceText.From(sw.ToString(), Encoding.UTF8));
// }
private static string GetSourceText(FileModel model)
{
using var sw = new StringWriter();
using var tw = new IndentedTextWriter(sw);
tw.WriteLine("// <AutoGenerated />");
tw.WriteLine("#pragma warning disable CS1066");
tw.WriteLine($"namespace {model.Namespace};");
foreach (var className in model.ClassHierarchy)
{
tw.WriteLine($"public partial class {className}");
tw.Write("{");
tw.Indent ++;
}
foreach (var method in model.Methods)
{
tw.WriteLine();
tw.WriteLine("[NadekoCommand]");
tw.WriteLine("[Aliases]");
tw.WriteLine($"public partial {method.ReturnType} {method.MethodName}({string.Join(", ", method.Params)});");
}
foreach (var _ in model.ClassHierarchy)
{
tw.Indent --;
tw.WriteLine("}");
}
tw.Flush();
return sw.ToString();
}
private static IReadOnlyCollection<FileModel> GetModels(Compilation compilation,
in ImmutableArray<MethodDeclarationSyntax> methods,
CancellationToken cancel)
{
var models = new List<FileModel>();
var methodModels = methods.Select(x => MethodDeclarationToMethodModel(compilation, x));
var groups = methodModels
.GroupBy(static x => $"{x.Namespace}.{string.Join(".", x.Classes)}");
foreach (var group in groups)
{
var elems = group.ToList();
var model = new FileModel()
{
Methods = elems,
Namespace = elems[0].Namespace,
ClassHierarchy = elems[0].Classes
};
models.Add(model);
}
return models;
}
private static MethodModel MethodDeclarationToMethodModel(Compilation comp, MethodDeclarationSyntax decl)
{
// SpinWait.SpinUntil(static () => Debugger.IsAttached);
var methodModel = new MethodModel();
var semanticModel = comp.GetSemanticModel(decl.SyntaxTree);
methodModel.Params = decl.ParameterList.Parameters
.Select(p =>
{
var prefix = p.Modifiers.Any(static x => x.IsKind(SyntaxKind.ParamsKeyword))
? "params "
: string.Empty;
var type = semanticModel
.GetTypeInfo(p.Type!)
.Type!
.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
var name = p.Identifier.Text;
var suffix = string.Empty;
if (p.Default is not null)
{
if (p.Default.Value is LiteralExpressionSyntax)
{
suffix = " = " + p.Default.Value;
}
else if (p.Default.Value is MemberAccessExpressionSyntax maes)
{
var maesSemModel = comp.GetSemanticModel(maes.SyntaxTree);
var sym = maesSemModel.GetSymbolInfo(maes.Name);
if (sym.Symbol is null)
{
suffix = " = " + p.Default.Value;
}
else
{
suffix = " = " + sym.Symbol.ToDisplayString();
}
}
}
return $"{prefix}{type} {name}{suffix}";
})
.ToList();
methodModel.MethodName = decl.Identifier.Text;
methodModel.ReturnType = decl.ReturnType.ToString();
methodModel.Namespace = GetNamespace(decl);
methodModel.Classes = GetClasses(decl);
return methodModel;
}
// private static IEnumerable<string> GetParams(Compilation compilation, MethodDeclarationSyntax method)
// {
// var semModel = compilation.GetSemanticModel(method.SyntaxTree);
// return method.ParameterList.Parameters.Select(p =>
// {
// var prefix = string.Empty;
//
// var typeSymbol = semModel.GetTypeInfo(p).Type;
//
// if (p.Modifiers.Any(static x => x.IsKind(SyntaxKind.ParamsKeyword)))
// prefix += "params ";
// return prefix + $"{typeSymbol?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)} {p.Identifier.ToString()}";
// });
// // foreach (var param in method.ParameterList.Parameters)
// // {
// // yield return param.ToString();
// // }
// }
//https://github.com/andrewlock/NetEscapades.EnumGenerators/blob/main/src/NetEscapades.EnumGenerators/EnumGenerator.cs
static string GetNamespace(MethodDeclarationSyntax declarationSyntax)
{
// determine the namespace the class is declared in, if any
var nameSpace = string.Empty;
var parentOfInterest = declarationSyntax.Parent;
while (parentOfInterest != null)
{
parentOfInterest = parentOfInterest.Parent;
if (parentOfInterest is BaseNamespaceDeclarationSyntax ns)
{
nameSpace = ns.Name.ToString();
while (true)
{
if (ns.Parent is not NamespaceDeclarationSyntax parent)
{
break;
}
ns = parent;
nameSpace = $"{ns.Name}.{nameSpace}";
}
return nameSpace;
}
}
return default;
}
static IReadOnlyCollection<string> GetClasses(MethodDeclarationSyntax declarationSyntax)
{
// determine the namespace the class is declared in, if any
var classes = new LinkedList<string>();
var parentOfInterest = declarationSyntax.Parent;
while (parentOfInterest is not null)
{
if (parentOfInterest is ClassDeclarationSyntax cds)
{
classes.AddFirst(cds.Identifier.ToString());
}
parentOfInterest = parentOfInterest.Parent;
}
Debug.WriteLine($"Method {declarationSyntax.Identifier.Text} has {classes.Count} classes");
return classes;
}
private static MethodDeclarationSyntax Transform(GeneratorSyntaxContext ctx, CancellationToken cancel)
{
var methodDecl = (MethodDeclarationSyntax)ctx.Node;
foreach (var attListSyntax in methodDecl.AttributeLists)
{
foreach (var attSyntax in attListSyntax.Attributes)
{
if (cancel.IsCancellationRequested)
return default;
var symbol = ModelExtensions.GetSymbolInfo(ctx.SemanticModel, attSyntax).Symbol;
if (symbol is not IMethodSymbol attSymbol)
continue;
if (attSymbol.ContainingType.ToDisplayString() == "NadekoBot.Common.CmdAttribute")
return methodDecl;
}
}
return default;
}
}

View File

@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>9</LangVersion> <LangVersion>latest</LangVersion>
<IncludeBuildOutput>false</IncludeBuildOutput> <IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup> </PropertyGroup>

View File

@@ -345,3 +345,4 @@ resharper_csharp_wrap_before_first_type_parameter_constraint = true
resharper_csharp_place_type_constraints_on_same_line = false resharper_csharp_place_type_constraints_on_same_line = false
resharper_csharp_wrap_before_extends_colon = true resharper_csharp_wrap_before_extends_colon = true
resharper_csharp_place_constructor_initializer_on_same_line = false resharper_csharp_place_constructor_initializer_on_same_line = false
resharper_force_attribute_style = separate

View File

@@ -28,7 +28,7 @@ public sealed class Bot
private readonly CommandService _commandService; private readonly CommandService _commandService;
private readonly DbService _db; private readonly DbService _db;
private readonly IBotCredsProvider _credsProvider; private readonly IBotCredsProvider _credsProvider;
private readonly InteractionService _interactionService; // private readonly InteractionService _interactionService;
public Bot(int shardId, int? totalShards) public Bot(int shardId, int? totalShards)
{ {
@@ -57,7 +57,7 @@ public sealed class Bot
_commandService = new(new() { CaseSensitiveCommands = false, DefaultRunMode = RunMode.Sync }); _commandService = new(new() { CaseSensitiveCommands = false, DefaultRunMode = RunMode.Sync });
_interactionService = new(Client.Rest); // _interactionService = new(Client.Rest);
#if GLOBAL_NADEKO || DEBUG #if GLOBAL_NADEKO || DEBUG
Client.Log += Client_Log; Client.Log += Client_Log;
@@ -85,7 +85,7 @@ public sealed class Bot
.AddRedis(_creds.RedisOptions) // redis .AddRedis(_creds.RedisOptions) // redis
.AddSingleton(Client) // discord socket client .AddSingleton(Client) // discord socket client
.AddSingleton(_commandService) .AddSingleton(_commandService)
.AddSingleton(_interactionService) // .AddSingleton(_interactionService)
.AddSingleton(this) .AddSingleton(this)
.AddSingleton<ISeria, JsonSeria>() .AddSingleton<ISeria, JsonSeria>()
.AddSingleton<IPubSub, RedisPubSub>() .AddSingleton<IPubSub, RedisPubSub>()
@@ -287,8 +287,7 @@ public sealed class Bot
await commandHandler.StartHandling(); await commandHandler.StartHandling();
await _commandService.AddModulesAsync(typeof(Bot).Assembly, Services); await _commandService.AddModulesAsync(typeof(Bot).Assembly, Services);
await _interactionService.AddModulesAsync(typeof(Bot).Assembly, Services); // await _interactionService.AddModulesAsync(typeof(Bot).Assembly, Services);
await _interactionService.RegisterCommandsToGuildAsync(117523346618318850);
IsReady = true; IsReady = true;
_ = Task.Run(ExecuteReadySubscriptions); _ = Task.Run(ExecuteReadySubscriptions);
Log.Information("Shard {ShardId} ready", Client.ShardId); Log.Information("Shard {ShardId} ready", Client.ShardId);

View File

@@ -37,12 +37,11 @@ public partial class Administration : NadekoModule<AdministrationService>
public Administration(ImageOnlyChannelService imageOnly) public Administration(ImageOnlyChannelService imageOnly)
=> _imageOnly = imageOnly; => _imageOnly = imageOnly;
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[BotPerm(GuildPerm.Administrator)] [BotPerm(GuildPerm.ManageGuild)]
public async Task ImageOnlyChannel(StoopidTime time = null) public async partial Task ImageOnlyChannel(StoopidTime time = null)
{ {
var newValue = _imageOnly.ToggleImageOnlyChannel(ctx.Guild.Id, ctx.Channel.Id); var newValue = _imageOnly.ToggleImageOnlyChannel(ctx.Guild.Id, ctx.Channel.Id);
if (newValue) if (newValue)
@@ -51,18 +50,16 @@ public partial class Administration : NadekoModule<AdministrationService>
await ReplyPendingLocalizedAsync(strs.imageonly_disable); await ReplyPendingLocalizedAsync(strs.imageonly_disable);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(ChannelPerm.ManageChannels)] [UserPerm(ChannelPerm.ManageChannels)]
[BotPerm(ChannelPerm.ManageChannels)] [BotPerm(ChannelPerm.ManageChannels)]
public async Task Slowmode(StoopidTime time = null) public async partial Task Slowmode(StoopidTime time = null)
{ {
var seconds = (int?)time?.Time.TotalSeconds ?? 0; var seconds = (int?)time?.Time.TotalSeconds ?? 0;
if (time is not null && (time.Time < TimeSpan.FromSeconds(0) || time.Time > TimeSpan.FromHours(6))) if (time is not null && (time.Time < TimeSpan.FromSeconds(0) || time.Time > TimeSpan.FromHours(6)))
return; return;
await ((ITextChannel)ctx.Channel).ModifyAsync(tcp => await ((ITextChannel)ctx.Channel).ModifyAsync(tcp =>
{ {
tcp.SlowModeInterval = seconds; tcp.SlowModeInterval = seconds;
@@ -71,13 +68,12 @@ public partial class Administration : NadekoModule<AdministrationService>
await ctx.OkAsync(); await ctx.OkAsync();
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[BotPerm(GuildPerm.ManageMessages)] [BotPerm(GuildPerm.ManageMessages)]
[Priority(2)] [Priority(2)]
public async Task Delmsgoncmd(List _) public async partial Task Delmsgoncmd(List _)
{ {
var guild = (SocketGuild)ctx.Guild; var guild = (SocketGuild)ctx.Guild;
var (enabled, channels) = _service.GetDelMsgOnCmdData(ctx.Guild.Id); var (enabled, channels) = _service.GetDelMsgOnCmdData(ctx.Guild.Id);
@@ -103,13 +99,12 @@ public partial class Administration : NadekoModule<AdministrationService>
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[BotPerm(GuildPerm.ManageMessages)] [BotPerm(GuildPerm.ManageMessages)]
[Priority(1)] [Priority(1)]
public async Task Delmsgoncmd(Server _ = Server.Server) public async partial Task Delmsgoncmd(Server _ = Server.Server)
{ {
if (_service.ToggleDeleteMessageOnCommand(ctx.Guild.Id)) if (_service.ToggleDeleteMessageOnCommand(ctx.Guild.Id))
{ {
@@ -123,22 +118,20 @@ public partial class Administration : NadekoModule<AdministrationService>
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[BotPerm(GuildPerm.ManageMessages)] [BotPerm(GuildPerm.ManageMessages)]
[Priority(0)] [Priority(0)]
public Task Delmsgoncmd(Channel _, State s, ITextChannel ch) public partial Task Delmsgoncmd(Channel _, State s, ITextChannel ch)
=> Delmsgoncmd(_, s, ch.Id); => Delmsgoncmd(_, s, ch.Id);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[BotPerm(GuildPerm.ManageMessages)] [BotPerm(GuildPerm.ManageMessages)]
[Priority(1)] [Priority(1)]
public async Task Delmsgoncmd(Channel _, State s, ulong? chId = null) public async partial Task Delmsgoncmd(Channel _, State s, ulong? chId = null)
{ {
var actualChId = chId ?? ctx.Channel.Id; var actualChId = chId ?? ctx.Channel.Id;
await _service.SetDelMsgOnCmdState(ctx.Guild.Id, actualChId, s); await _service.SetDelMsgOnCmdState(ctx.Guild.Id, actualChId, s);
@@ -151,78 +144,71 @@ public partial class Administration : NadekoModule<AdministrationService>
await ReplyConfirmLocalizedAsync(strs.delmsg_channel_inherit); await ReplyConfirmLocalizedAsync(strs.delmsg_channel_inherit);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.DeafenMembers)] [UserPerm(GuildPerm.DeafenMembers)]
[BotPerm(GuildPerm.DeafenMembers)] [BotPerm(GuildPerm.DeafenMembers)]
public async Task Deafen(params IGuildUser[] users) public async partial Task Deafen(params IGuildUser[] users)
{ {
await _service.DeafenUsers(true, users); await _service.DeafenUsers(true, users);
await ReplyConfirmLocalizedAsync(strs.deafen); await ReplyConfirmLocalizedAsync(strs.deafen);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.DeafenMembers)] [UserPerm(GuildPerm.DeafenMembers)]
[BotPerm(GuildPerm.DeafenMembers)] [BotPerm(GuildPerm.DeafenMembers)]
public async Task UnDeafen(params IGuildUser[] users) public async partial Task UnDeafen(params IGuildUser[] users)
{ {
await _service.DeafenUsers(false, users); await _service.DeafenUsers(false, users);
await ReplyConfirmLocalizedAsync(strs.undeafen); await ReplyConfirmLocalizedAsync(strs.undeafen);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageChannels)] [UserPerm(GuildPerm.ManageChannels)]
[BotPerm(GuildPerm.ManageChannels)] [BotPerm(GuildPerm.ManageChannels)]
public async Task DelVoiChanl([Leftover] IVoiceChannel voiceChannel) public async partial Task DelVoiChanl([Leftover] IVoiceChannel voiceChannel)
{ {
await voiceChannel.DeleteAsync(); await voiceChannel.DeleteAsync();
await ReplyConfirmLocalizedAsync(strs.delvoich(Format.Bold(voiceChannel.Name))); await ReplyConfirmLocalizedAsync(strs.delvoich(Format.Bold(voiceChannel.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageChannels)] [UserPerm(GuildPerm.ManageChannels)]
[BotPerm(GuildPerm.ManageChannels)] [BotPerm(GuildPerm.ManageChannels)]
public async Task CreatVoiChanl([Leftover] string channelName) public async partial Task CreatVoiChanl([Leftover] string channelName)
{ {
var ch = await ctx.Guild.CreateVoiceChannelAsync(channelName); var ch = await ctx.Guild.CreateVoiceChannelAsync(channelName);
await ReplyConfirmLocalizedAsync(strs.createvoich(Format.Bold(ch.Name))); await ReplyConfirmLocalizedAsync(strs.createvoich(Format.Bold(ch.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageChannels)] [UserPerm(GuildPerm.ManageChannels)]
[BotPerm(GuildPerm.ManageChannels)] [BotPerm(GuildPerm.ManageChannels)]
public async Task DelTxtChanl([Leftover] ITextChannel toDelete) public async partial Task DelTxtChanl([Leftover] ITextChannel toDelete)
{ {
await toDelete.DeleteAsync(); await toDelete.DeleteAsync();
await ReplyConfirmLocalizedAsync(strs.deltextchan(Format.Bold(toDelete.Name))); await ReplyConfirmLocalizedAsync(strs.deltextchan(Format.Bold(toDelete.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageChannels)] [UserPerm(GuildPerm.ManageChannels)]
[BotPerm(GuildPerm.ManageChannels)] [BotPerm(GuildPerm.ManageChannels)]
public async Task CreaTxtChanl([Leftover] string channelName) public async partial Task CreaTxtChanl([Leftover] string channelName)
{ {
var txtCh = await ctx.Guild.CreateTextChannelAsync(channelName); var txtCh = await ctx.Guild.CreateTextChannelAsync(channelName);
await ReplyConfirmLocalizedAsync(strs.createtextchan(Format.Bold(txtCh.Name))); await ReplyConfirmLocalizedAsync(strs.createtextchan(Format.Bold(txtCh.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageChannels)] [UserPerm(GuildPerm.ManageChannels)]
[BotPerm(GuildPerm.ManageChannels)] [BotPerm(GuildPerm.ManageChannels)]
public async Task SetTopic([Leftover] string topic = null) public async partial Task SetTopic([Leftover] string topic = null)
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;
topic ??= ""; topic ??= "";
@@ -230,24 +216,22 @@ public partial class Administration : NadekoModule<AdministrationService>
await ReplyConfirmLocalizedAsync(strs.set_topic); await ReplyConfirmLocalizedAsync(strs.set_topic);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageChannels)] [UserPerm(GuildPerm.ManageChannels)]
[BotPerm(GuildPerm.ManageChannels)] [BotPerm(GuildPerm.ManageChannels)]
public async Task SetChanlName([Leftover] string name) public async partial Task SetChanlName([Leftover] string name)
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;
await channel.ModifyAsync(c => c.Name = name); await channel.ModifyAsync(c => c.Name = name);
await ReplyConfirmLocalizedAsync(strs.set_channel_name); await ReplyConfirmLocalizedAsync(strs.set_channel_name);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageChannels)] [UserPerm(GuildPerm.ManageChannels)]
[BotPerm(GuildPerm.ManageChannels)] [BotPerm(GuildPerm.ManageChannels)]
public async Task NsfwToggle() public async partial Task NsfwToggle()
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;
var isEnabled = channel.IsNsfw; var isEnabled = channel.IsNsfw;
@@ -260,19 +244,17 @@ public partial class Administration : NadekoModule<AdministrationService>
await ReplyConfirmLocalizedAsync(strs.nsfw_set_true); await ReplyConfirmLocalizedAsync(strs.nsfw_set_true);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(ChannelPerm.ManageMessages)] [UserPerm(ChannelPerm.ManageMessages)]
[Priority(0)] [Priority(0)]
public Task Edit(ulong messageId, [Leftover] string text) public partial Task Edit(ulong messageId, [Leftover] string text)
=> Edit((ITextChannel)ctx.Channel, messageId, text); => Edit((ITextChannel)ctx.Channel, messageId, text);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(1)] [Priority(1)]
public async Task Edit(ITextChannel channel, ulong messageId, [Leftover] string text) public async partial Task Edit(ITextChannel channel, ulong messageId, [Leftover] string text)
{ {
var userPerms = ((SocketGuildUser)ctx.User).GetPermissions(channel); var userPerms = ((SocketGuildUser)ctx.User).GetPermissions(channel);
var botPerms = ((SocketGuild)ctx.Guild).CurrentUser.GetPermissions(channel); var botPerms = ((SocketGuild)ctx.Guild).CurrentUser.GetPermissions(channel);
@@ -291,18 +273,16 @@ public partial class Administration : NadekoModule<AdministrationService>
await _service.EditMessage(ctx, channel, messageId, text); await _service.EditMessage(ctx, channel, messageId, text);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(ChannelPerm.ManageMessages)] [UserPerm(ChannelPerm.ManageMessages)]
[BotPerm(ChannelPerm.ManageMessages)] [BotPerm(ChannelPerm.ManageMessages)]
public Task Delete(ulong messageId, StoopidTime time = null) public partial Task Delete(ulong messageId, StoopidTime time = null)
=> Delete((ITextChannel)ctx.Channel, messageId, time); => Delete((ITextChannel)ctx.Channel, messageId, time);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Delete(ITextChannel channel, ulong messageId, StoopidTime time = null) public async partial Task Delete(ITextChannel channel, ulong messageId, StoopidTime time = null)
=> await InternalMessageAction(channel, messageId, time, msg => msg.DeleteAsync()); => await InternalMessageAction(channel, messageId, time, msg => msg.DeleteAsync());
private async Task InternalMessageAction( private async Task InternalMessageAction(

View File

@@ -6,14 +6,13 @@ namespace NadekoBot.Modules.Administration;
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class AutoAssignRoleCommands : NadekoSubmodule<AutoAssignRoleService> public partial class AutoAssignRoleCommands : NadekoSubmodule<AutoAssignRoleService>
{ {
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
public async Task AutoAssignRole([Leftover] IRole role) public async partial Task AutoAssignRole([Leftover] IRole role)
{ {
var guser = (IGuildUser)ctx.User; var guser = (IGuildUser)ctx.User;
if (role.Id == ctx.Guild.EveryoneRole.Id) if (role.Id == ctx.Guild.EveryoneRole.Id)
@@ -35,12 +34,11 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.aar_role_removed(Format.Bold(role.ToString()))); await ReplyConfirmLocalizedAsync(strs.aar_role_removed(Format.Bold(role.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
public async Task AutoAssignRole() public async partial Task AutoAssignRole()
{ {
if (!_service.TryGetRoles(ctx.Guild.Id, out var roles)) if (!_service.TryGetRoles(ctx.Guild.Id, out var roles))
{ {

View File

@@ -8,7 +8,7 @@ namespace NadekoBot.Modules.Administration
{ {
[Group] [Group]
[OwnerOnly] [OwnerOnly]
public class DangerousCommands : NadekoSubmodule<DangerousCommandsService> public partial class DangerousCommands : NadekoSubmodule<DangerousCommandsService>
{ {
private async Task InternalExecSql(string sql, params object[] reps) private async Task InternalExecSql(string sql, params object[] reps)
{ {
@@ -31,10 +31,9 @@ namespace NadekoBot.Modules.Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task SqlSelect([Leftover] string sql) public partial Task SqlSelect([Leftover] string sql)
{ {
var result = _service.SelectSql(sql); var result = _service.SelectSql(sql);
@@ -56,52 +55,44 @@ namespace NadekoBot.Modules.Administration
20); 20);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task SqlExec([Leftover] string sql) public partial Task SqlExec([Leftover] string sql)
=> InternalExecSql(sql); => InternalExecSql(sql);
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task DeleteWaifus() public partial Task DeleteWaifus()
=> SqlExec(DangerousCommandsService.WaifusDeleteSql); => SqlExec(DangerousCommandsService.WaifusDeleteSql);
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task DeleteWaifu(IUser user) public partial Task DeleteWaifu(IUser user)
=> DeleteWaifu(user.Id); => DeleteWaifu(user.Id);
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task DeleteWaifu(ulong userId) public partial Task DeleteWaifu(ulong userId)
=> InternalExecSql(DangerousCommandsService.WaifuDeleteSql, userId); => InternalExecSql(DangerousCommandsService.WaifuDeleteSql, userId);
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task DeleteCurrency() public partial Task DeleteCurrency()
=> SqlExec(DangerousCommandsService.CurrencyDeleteSql); => SqlExec(DangerousCommandsService.CurrencyDeleteSql);
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task DeletePlaylists() public partial Task DeletePlaylists()
=> SqlExec(DangerousCommandsService.MusicPlaylistDeleteSql); => SqlExec(DangerousCommandsService.MusicPlaylistDeleteSql);
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task DeleteXp() public partial Task DeleteXp()
=> SqlExec(DangerousCommandsService.XpDeleteSql); => SqlExec(DangerousCommandsService.XpDeleteSql);
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task PurgeUser(ulong userId) public async partial Task PurgeUser(ulong userId)
{ {
var embed = _eb.Create() var embed = _eb.Create()
.WithDescription(GetText(strs.purge_user_confirm(Format.Bold(userId.ToString())))); .WithDescription(GetText(strs.purge_user_confirm(Format.Bold(userId.ToString()))));
@@ -112,14 +103,13 @@ namespace NadekoBot.Modules.Administration
await ctx.OkAsync(); await ctx.OkAsync();
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task PurgeUser([Leftover] IUser user) public partial Task PurgeUser([Leftover] IUser user)
=> PurgeUser(user.Id); => PurgeUser(user.Id);
//[NadekoCommand, Usage, Description, Aliases] //[NadekoCommand, Usage, Description, Aliases]
//[OwnerOnly] //[OwnerOnly]
//public Task DeleteUnusedCrnQ() => //public partial Task DeleteUnusedCrnQ() =>
// SqlExec(DangerousCommandsService.DeleteUnusedCustomReactionsAndQuotes); // SqlExec(DangerousCommandsService.DeleteUnusedCustomReactionsAndQuotes);
} }
} }

View File

@@ -6,14 +6,13 @@ namespace NadekoBot.Modules.Administration;
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class GameChannelCommands : NadekoSubmodule<GameVoiceChannelService> public partial class GameVoiceChannelCommands : NadekoSubmodule<GameVoiceChannelService>
{ {
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[BotPerm(GuildPerm.MoveMembers)] [BotPerm(GuildPerm.MoveMembers)]
public async Task GameVoiceChannel() public async partial Task GameVoiceChannel()
{ {
var vch = ((IGuildUser)ctx.User).VoiceChannel; var vch = ((IGuildUser)ctx.User).VoiceChannel;

View File

@@ -3,13 +3,12 @@ namespace NadekoBot.Modules.Administration;
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class ServerGreetCommands : NadekoSubmodule<GreetSettingsService> public partial class GreetCommands : NadekoSubmodule<GreetService>
{ {
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageGuild)] [UserPerm(GuildPerm.ManageGuild)]
public async Task Boost() public async partial Task Boost()
{ {
var enabled = await _service.ToggleBoost(ctx.Guild.Id, ctx.Channel.Id); var enabled = await _service.ToggleBoost(ctx.Guild.Id, ctx.Channel.Id);
@@ -19,11 +18,10 @@ public partial class Administration
await ReplyPendingLocalizedAsync(strs.boost_off); await ReplyPendingLocalizedAsync(strs.boost_off);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageGuild)] [UserPerm(GuildPerm.ManageGuild)]
public async Task BoostDel(int timer = 30) public async partial Task BoostDel(int timer = 30)
{ {
if (timer is < 0 or > 600) if (timer is < 0 or > 600)
return; return;
@@ -36,11 +34,10 @@ public partial class Administration
await ReplyPendingLocalizedAsync(strs.boostdel_off); await ReplyPendingLocalizedAsync(strs.boostdel_off);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageGuild)] [UserPerm(GuildPerm.ManageGuild)]
public async Task BoostMsg([Leftover] string? text = null) public async partial Task BoostMsg([Leftover] string? text = null)
{ {
if (string.IsNullOrWhiteSpace(text)) if (string.IsNullOrWhiteSpace(text))
{ {
@@ -56,11 +53,10 @@ public partial class Administration
await ReplyPendingLocalizedAsync(strs.boostmsg_enable($"`{Prefix}boost`")); await ReplyPendingLocalizedAsync(strs.boostmsg_enable($"`{Prefix}boost`"));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageGuild)] [UserPerm(GuildPerm.ManageGuild)]
public async Task GreetDel(int timer = 30) public async partial Task GreetDel(int timer = 30)
{ {
if (timer is < 0 or > 600) if (timer is < 0 or > 600)
return; return;
@@ -73,11 +69,10 @@ public partial class Administration
await ReplyPendingLocalizedAsync(strs.greetdel_off); await ReplyPendingLocalizedAsync(strs.greetdel_off);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageGuild)] [UserPerm(GuildPerm.ManageGuild)]
public async Task Greet() public async partial Task Greet()
{ {
var enabled = await _service.SetGreet(ctx.Guild.Id, ctx.Channel.Id); var enabled = await _service.SetGreet(ctx.Guild.Id, ctx.Channel.Id);
@@ -87,11 +82,10 @@ public partial class Administration
await ReplyPendingLocalizedAsync(strs.greet_off); await ReplyPendingLocalizedAsync(strs.greet_off);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageGuild)] [UserPerm(GuildPerm.ManageGuild)]
public async Task GreetMsg([Leftover] string? text = null) public async partial Task GreetMsg([Leftover] string? text = null)
{ {
if (string.IsNullOrWhiteSpace(text)) if (string.IsNullOrWhiteSpace(text))
{ {
@@ -108,11 +102,10 @@ public partial class Administration
await ReplyPendingLocalizedAsync(strs.greetmsg_enable($"`{Prefix}greet`")); await ReplyPendingLocalizedAsync(strs.greetmsg_enable($"`{Prefix}greet`"));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageGuild)] [UserPerm(GuildPerm.ManageGuild)]
public async Task GreetDm() public async partial Task GreetDm()
{ {
var enabled = await _service.SetGreetDm(ctx.Guild.Id); var enabled = await _service.SetGreetDm(ctx.Guild.Id);
@@ -122,11 +115,10 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.greetdm_off); await ReplyConfirmLocalizedAsync(strs.greetdm_off);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageGuild)] [UserPerm(GuildPerm.ManageGuild)]
public async Task GreetDmMsg([Leftover] string? text = null) public async partial Task GreetDmMsg([Leftover] string? text = null)
{ {
if (string.IsNullOrWhiteSpace(text)) if (string.IsNullOrWhiteSpace(text))
{ {
@@ -142,11 +134,10 @@ public partial class Administration
await ReplyPendingLocalizedAsync(strs.greetdmmsg_enable($"`{Prefix}greetdm`")); await ReplyPendingLocalizedAsync(strs.greetdmmsg_enable($"`{Prefix}greetdm`"));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageGuild)] [UserPerm(GuildPerm.ManageGuild)]
public async Task Bye() public async partial Task Bye()
{ {
var enabled = await _service.SetBye(ctx.Guild.Id, ctx.Channel.Id); var enabled = await _service.SetBye(ctx.Guild.Id, ctx.Channel.Id);
@@ -156,11 +147,10 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.bye_off); await ReplyConfirmLocalizedAsync(strs.bye_off);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageGuild)] [UserPerm(GuildPerm.ManageGuild)]
public async Task ByeMsg([Leftover] string? text = null) public async partial Task ByeMsg([Leftover] string? text = null)
{ {
if (string.IsNullOrWhiteSpace(text)) if (string.IsNullOrWhiteSpace(text))
{ {
@@ -176,11 +166,10 @@ public partial class Administration
await ReplyPendingLocalizedAsync(strs.byemsg_enable($"`{Prefix}bye`")); await ReplyPendingLocalizedAsync(strs.byemsg_enable($"`{Prefix}bye`"));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageGuild)] [UserPerm(GuildPerm.ManageGuild)]
public async Task ByeDel(int timer = 30) public async partial Task ByeDel(int timer = 30)
{ {
await _service.SetByeDel(ctx.Guild.Id, timer); await _service.SetByeDel(ctx.Guild.Id, timer);
@@ -191,12 +180,11 @@ public partial class Administration
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageGuild)] [UserPerm(GuildPerm.ManageGuild)]
[Ratelimit(5)] [Ratelimit(5)]
public async Task ByeTest([Leftover] IGuildUser? user = null) public async partial Task ByeTest([Leftover] IGuildUser? user = null)
{ {
user ??= (IGuildUser)ctx.User; user ??= (IGuildUser)ctx.User;
@@ -205,12 +193,11 @@ public partial class Administration
if (!enabled) await ReplyPendingLocalizedAsync(strs.byemsg_enable($"`{Prefix}bye`")); if (!enabled) await ReplyPendingLocalizedAsync(strs.byemsg_enable($"`{Prefix}bye`"));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageGuild)] [UserPerm(GuildPerm.ManageGuild)]
[Ratelimit(5)] [Ratelimit(5)]
public async Task GreetTest([Leftover] IGuildUser? user = null) public async partial Task GreetTest([Leftover] IGuildUser? user = null)
{ {
user ??= (IGuildUser)ctx.User; user ??= (IGuildUser)ctx.User;
@@ -219,12 +206,11 @@ public partial class Administration
if (!enabled) await ReplyPendingLocalizedAsync(strs.greetmsg_enable($"`{Prefix}greet`")); if (!enabled) await ReplyPendingLocalizedAsync(strs.greetmsg_enable($"`{Prefix}greet`"));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageGuild)] [UserPerm(GuildPerm.ManageGuild)]
[Ratelimit(5)] [Ratelimit(5)]
public async Task GreetDmTest([Leftover] IGuildUser? user = null) public async partial Task GreetDmTest([Leftover] IGuildUser? user = null)
{ {
user ??= (IGuildUser)ctx.User; user ??= (IGuildUser)ctx.User;

View File

@@ -3,7 +3,7 @@ using NadekoBot.Services.Database.Models;
namespace NadekoBot.Services; namespace NadekoBot.Services;
public class GreetSettingsService : INService public class GreetService : INService
{ {
public bool GroupGreets public bool GroupGreets
=> _bss.Data.GroupGreets; => _bss.Data.GroupGreets;
@@ -17,7 +17,7 @@ public class GreetSettingsService : INService
private readonly GreetGrouper<IUser> _byes = new(); private readonly GreetGrouper<IUser> _byes = new();
private readonly BotConfigService _bss; private readonly BotConfigService _bss;
public GreetSettingsService( public GreetService(
DiscordSocketClient client, DiscordSocketClient client,
Bot bot, Bot bot,
DbService db, DbService db,

View File

@@ -6,7 +6,7 @@ namespace NadekoBot.Modules.Administration;
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class LocalizationCommands : NadekoSubmodule public partial class LocalizationCommands : NadekoSubmodule
{ {
private static readonly IReadOnlyDictionary<string, string> supportedLocales = new Dictionary<string, string> private static readonly IReadOnlyDictionary<string, string> supportedLocales = new Dictionary<string, string>
{ {
@@ -38,20 +38,18 @@ public partial class Administration
{ "uk-UA", "Українська, Україна" } { "uk-UA", "Українська, Україна" }
}; };
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(0)] [Priority(0)]
public async Task LanguageSet() public async partial Task LanguageSet()
=> await ReplyConfirmLocalizedAsync(strs.lang_set_show(Format.Bold(Culture.ToString()), => await ReplyConfirmLocalizedAsync(strs.lang_set_show(Format.Bold(Culture.ToString()),
Format.Bold(Culture.NativeName))); Format.Bold(Culture.NativeName)));
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[Priority(1)] [Priority(1)]
public async Task LanguageSet(string name) public async partial Task LanguageSet(string name)
{ {
try try
{ {
@@ -75,18 +73,16 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task LanguageSetDefault()
public async Task LanguageSetDefault()
{ {
var cul = Localization.DefaultCultureInfo; var cul = Localization.DefaultCultureInfo;
await ReplyErrorLocalizedAsync(strs.lang_set_bot_show(cul, cul.NativeName)); await ReplyErrorLocalizedAsync(strs.lang_set_bot_show(cul, cul.NativeName));
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task LanguageSetDefault(string name) public async partial Task LanguageSetDefault(string name)
{ {
try try
{ {
@@ -111,9 +107,8 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task LanguagesList()
public async Task LanguagesList()
=> await ctx.Channel.EmbedAsync(_eb.Create() => await ctx.Channel.EmbedAsync(_eb.Create()
.WithOkColor() .WithOkColor()
.WithTitle(GetText(strs.lang_list)) .WithTitle(GetText(strs.lang_list))

View File

@@ -1,167 +0,0 @@
#nullable disable
using NadekoBot.Common.TypeReaders.Models;
using NadekoBot.Modules.Administration.Services;
using NadekoBot.Services.Database.Models;
namespace NadekoBot.Modules.Administration;
public partial class Administration
{
[Group]
[NoPublicBot]
public class LogCommands : NadekoSubmodule<ILogCommandService>
{
[NadekoCommand]
[Aliases]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)]
[OwnerOnly]
public async Task LogServer(PermissionAction action)
{
await _service.LogServer(ctx.Guild.Id, ctx.Channel.Id, action.Value);
if (action.Value)
await ReplyConfirmLocalizedAsync(strs.log_all);
else
await ReplyConfirmLocalizedAsync(strs.log_disabled);
}
[NadekoCommand]
[Aliases]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)]
[OwnerOnly]
public async Task LogIgnore()
{
var settings = _service.GetGuildLogSettings(ctx.Guild.Id);
var chs = settings?.LogIgnores.Where(x => x.ItemType == IgnoredItemType.Channel).ToList()
?? new List<IgnoredLogItem>();
var usrs = settings?.LogIgnores.Where(x => x.ItemType == IgnoredItemType.User).ToList()
?? new List<IgnoredLogItem>();
var eb = _eb.Create(ctx)
.WithOkColor()
.AddField(GetText(strs.log_ignored_channels),
chs.Count == 0
? "-"
: string.Join('\n', chs.Select(x => $"{x.LogItemId} | <#{x.LogItemId}>")))
.AddField(GetText(strs.log_ignored_users),
usrs.Count == 0
? "-"
: string.Join('\n', usrs.Select(x => $"{x.LogItemId} | <@{x.LogItemId}>")));
await ctx.Channel.EmbedAsync(eb);
}
[NadekoCommand]
[Aliases]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)]
[OwnerOnly]
public async Task LogIgnore([Leftover] ITextChannel target)
{
target ??= (ITextChannel)ctx.Channel;
var removed = _service.LogIgnore(ctx.Guild.Id, target.Id, IgnoredItemType.Channel);
if (!removed)
await ReplyConfirmLocalizedAsync(
strs.log_ignore_chan(Format.Bold(target.Mention + "(" + target.Id + ")")));
else
await ReplyConfirmLocalizedAsync(
strs.log_not_ignore_chan(Format.Bold(target.Mention + "(" + target.Id + ")")));
}
[NadekoCommand]
[Aliases]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)]
[OwnerOnly]
public async Task LogIgnore([Leftover] IUser target)
{
var removed = _service.LogIgnore(ctx.Guild.Id, target.Id, IgnoredItemType.User);
if (!removed)
await ReplyConfirmLocalizedAsync(
strs.log_ignore_user(Format.Bold(target.Mention + "(" + target.Id + ")")));
else
await ReplyConfirmLocalizedAsync(
strs.log_not_ignore_user(Format.Bold(target.Mention + "(" + target.Id + ")")));
}
[NadekoCommand]
[Aliases]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)]
[OwnerOnly]
public async Task LogEvents()
{
var logSetting = _service.GetGuildLogSettings(ctx.Guild.Id);
var str = string.Join("\n",
Enum.GetNames(typeof(LogType))
.Select(x =>
{
var val = logSetting is null ? null : GetLogProperty(logSetting, Enum.Parse<LogType>(x));
if (val != null)
return $"{Format.Bold(x)} <#{val}>";
return Format.Bold(x);
}));
await SendConfirmAsync(Format.Bold(GetText(strs.log_events)) + "\n" + str);
}
private static ulong? GetLogProperty(LogSetting l, LogType type)
{
switch (type)
{
case LogType.Other:
return l.LogOtherId;
case LogType.MessageUpdated:
return l.MessageUpdatedId;
case LogType.MessageDeleted:
return l.MessageDeletedId;
case LogType.UserJoined:
return l.UserJoinedId;
case LogType.UserLeft:
return l.UserLeftId;
case LogType.UserBanned:
return l.UserBannedId;
case LogType.UserUnbanned:
return l.UserUnbannedId;
case LogType.UserUpdated:
return l.UserUpdatedId;
case LogType.ChannelCreated:
return l.ChannelCreatedId;
case LogType.ChannelDestroyed:
return l.ChannelDestroyedId;
case LogType.ChannelUpdated:
return l.ChannelUpdatedId;
case LogType.UserPresence:
return l.LogUserPresenceId;
case LogType.VoicePresence:
return l.LogVoicePresenceId;
case LogType.VoicePresenceTTS:
return l.LogVoicePresenceTTSId;
case LogType.UserMuted:
return l.UserMutedId;
default:
return null;
}
}
[NadekoCommand]
[Aliases]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)]
[OwnerOnly]
public async Task Log(LogType type)
{
var val = _service.Log(ctx.Guild.Id, ctx.Channel.Id, type);
if (val)
await ReplyConfirmLocalizedAsync(strs.log(Format.Bold(type.ToString())));
else
await ReplyConfirmLocalizedAsync(strs.log_stop(Format.Bold(type.ToString())));
}
}
}

View File

@@ -7,7 +7,7 @@ namespace NadekoBot.Modules.Administration;
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class MuteCommands : NadekoSubmodule<MuteService> public partial class MuteCommands : NadekoSubmodule<MuteService>
{ {
private async Task<bool> VerifyMutePermissions(IGuildUser runnerUser, IGuildUser targetUser) private async Task<bool> VerifyMutePermissions(IGuildUser runnerUser, IGuildUser targetUser)
{ {
@@ -23,11 +23,10 @@ public partial class Administration
return true; return true;
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
public async Task MuteRole([Leftover] IRole role = null) public async partial Task MuteRole([Leftover] IRole role = null)
{ {
if (role is null) if (role is null)
{ {
@@ -48,12 +47,11 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.mute_role_set); await ReplyConfirmLocalizedAsync(strs.mute_role_set);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles | GuildPerm.MuteMembers)] [UserPerm(GuildPerm.ManageRoles | GuildPerm.MuteMembers)]
[Priority(0)] [Priority(0)]
public async Task Mute(IGuildUser target, [Leftover] string reason = "") public async partial Task Mute(IGuildUser target, [Leftover] string reason = "")
{ {
try try
{ {
@@ -70,12 +68,11 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles | GuildPerm.MuteMembers)] [UserPerm(GuildPerm.ManageRoles | GuildPerm.MuteMembers)]
[Priority(1)] [Priority(1)]
public async Task Mute(StoopidTime time, IGuildUser user, [Leftover] string reason = "") public async partial Task Mute(StoopidTime time, IGuildUser user, [Leftover] string reason = "")
{ {
if (time.Time < TimeSpan.FromMinutes(1) || time.Time > TimeSpan.FromDays(49)) if (time.Time < TimeSpan.FromMinutes(1) || time.Time > TimeSpan.FromDays(49))
return; return;
@@ -95,11 +92,10 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles | GuildPerm.MuteMembers)] [UserPerm(GuildPerm.ManageRoles | GuildPerm.MuteMembers)]
public async Task Unmute(IGuildUser user, [Leftover] string reason = "") public async partial Task Unmute(IGuildUser user, [Leftover] string reason = "")
{ {
try try
{ {
@@ -112,12 +108,11 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[Priority(0)] [Priority(0)]
public async Task ChatMute(IGuildUser user, [Leftover] string reason = "") public async partial Task ChatMute(IGuildUser user, [Leftover] string reason = "")
{ {
try try
{ {
@@ -134,12 +129,11 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[Priority(1)] [Priority(1)]
public async Task ChatMute(StoopidTime time, IGuildUser user, [Leftover] string reason = "") public async partial Task ChatMute(StoopidTime time, IGuildUser user, [Leftover] string reason = "")
{ {
if (time.Time < TimeSpan.FromMinutes(1) || time.Time > TimeSpan.FromDays(49)) if (time.Time < TimeSpan.FromMinutes(1) || time.Time > TimeSpan.FromDays(49))
return; return;
@@ -159,11 +153,10 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
public async Task ChatUnmute(IGuildUser user, [Leftover] string reason = "") public async partial Task ChatUnmute(IGuildUser user, [Leftover] string reason = "")
{ {
try try
{ {
@@ -176,12 +169,11 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.MuteMembers)] [UserPerm(GuildPerm.MuteMembers)]
[Priority(0)] [Priority(0)]
public async Task VoiceMute(IGuildUser user, [Leftover] string reason = "") public async partial Task VoiceMute(IGuildUser user, [Leftover] string reason = "")
{ {
try try
{ {
@@ -197,12 +189,11 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.MuteMembers)] [UserPerm(GuildPerm.MuteMembers)]
[Priority(1)] [Priority(1)]
public async Task VoiceMute(StoopidTime time, IGuildUser user, [Leftover] string reason = "") public async partial Task VoiceMute(StoopidTime time, IGuildUser user, [Leftover] string reason = "")
{ {
if (time.Time < TimeSpan.FromMinutes(1) || time.Time > TimeSpan.FromDays(49)) if (time.Time < TimeSpan.FromMinutes(1) || time.Time > TimeSpan.FromDays(49))
return; return;
@@ -221,11 +212,10 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.MuteMembers)] [UserPerm(GuildPerm.MuteMembers)]
public async Task VoiceUnmute(IGuildUser user, [Leftover] string reason = "") public async partial Task VoiceUnmute(IGuildUser user, [Leftover] string reason = "")
{ {
try try
{ {

View File

@@ -7,15 +7,14 @@ namespace NadekoBot.Modules.Administration;
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class DiscordPermOverrideCommands : NadekoSubmodule<DiscordPermOverrideService> public partial class DiscordPermOverrideCommands : NadekoSubmodule<DiscordPermOverrideService>
{ {
// override stats, it should require that the user has managessages guild permission // override stats, it should require that the user has managessages guild permission
// .po 'stats' add user guild managemessages // .po 'stats' add user guild managemessages
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task DiscordPermOverride(CommandOrCrInfo cmd, params GuildPerm[] perms) public async partial Task DiscordPermOverride(CommandOrCrInfo cmd, params GuildPerm[] perms)
{ {
if (perms is null || perms.Length == 0) if (perms is null || perms.Length == 0)
{ {
@@ -31,11 +30,10 @@ public partial class Administration
Format.Code(cmd.Name))); Format.Code(cmd.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task DiscordPermOverrideReset() public async partial Task DiscordPermOverrideReset()
{ {
var result = await PromptUserConfirmAsync(_eb.Create() var result = await PromptUserConfirmAsync(_eb.Create()
.WithOkColor() .WithOkColor()
@@ -48,11 +46,10 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.perm_override_all); await ReplyConfirmLocalizedAsync(strs.perm_override_all);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task DiscordPermOverrideList(int page = 1) public async partial Task DiscordPermOverrideList(int page = 1)
{ {
if (--page < 0) if (--page < 0)
return; return;

View File

@@ -6,12 +6,11 @@ namespace NadekoBot.Modules.Administration;
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class PlayingRotateCommands : NadekoSubmodule<PlayingRotateService> public partial class PlayingRotateCommands : NadekoSubmodule<PlayingRotateService>
{ {
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task RotatePlaying() public async partial Task RotatePlaying()
{ {
if (_service.ToggleRotatePlaying()) if (_service.ToggleRotatePlaying())
await ReplyConfirmLocalizedAsync(strs.ropl_enabled); await ReplyConfirmLocalizedAsync(strs.ropl_enabled);
@@ -19,20 +18,18 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.ropl_disabled); await ReplyConfirmLocalizedAsync(strs.ropl_disabled);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task AddPlaying(ActivityType t, [Leftover] string status) public async partial Task AddPlaying(ActivityType t, [Leftover] string status)
{ {
await _service.AddPlaying(t, status); await _service.AddPlaying(t, status);
await ReplyConfirmLocalizedAsync(strs.ropl_added); await ReplyConfirmLocalizedAsync(strs.ropl_added);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task ListPlaying() public async partial Task ListPlaying()
{ {
var statuses = _service.GetRotatingStatuses(); var statuses = _service.GetRotatingStatuses();
@@ -48,10 +45,9 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task RemovePlaying(int index) public async partial Task RemovePlaying(int index)
{ {
index -= 1; index -= 1;

View File

@@ -4,33 +4,30 @@ namespace NadekoBot.Modules.Administration;
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class PrefixCommands : NadekoSubmodule public partial class PrefixCommands : NadekoSubmodule
{ {
public enum Set public enum Set
{ {
Set Set
} }
[NadekoCommand] [Cmd]
[Aliases]
[Priority(1)] [Priority(1)]
public async Task PrefixCommand() public async partial Task PrefixCommand()
=> await ReplyConfirmLocalizedAsync(strs.prefix_current(Format.Code(CmdHandler.GetPrefix(ctx.Guild)))); => await ReplyConfirmLocalizedAsync(strs.prefix_current(Format.Code(CmdHandler.GetPrefix(ctx.Guild))));
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[Priority(0)] [Priority(0)]
public Task PrefixCommand(Set _, [Leftover] string prefix) public partial Task PrefixCommand(Set _, [Leftover] string prefix)
=> PrefixCommand(prefix); => PrefixCommand(prefix);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[Priority(0)] [Priority(0)]
public async Task PrefixCommand([Leftover] string prefix) public async partial Task PrefixCommand([Leftover] string prefix)
{ {
if (string.IsNullOrWhiteSpace(prefix)) if (string.IsNullOrWhiteSpace(prefix))
return; return;
@@ -41,10 +38,9 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.prefix_new(Format.Code(oldPrefix), Format.Code(newPrefix))); await ReplyConfirmLocalizedAsync(strs.prefix_new(Format.Code(oldPrefix), Format.Code(newPrefix)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task DefPrefix([Leftover] string prefix = null) public async partial Task DefPrefix([Leftover] string prefix = null)
{ {
if (string.IsNullOrWhiteSpace(prefix)) if (string.IsNullOrWhiteSpace(prefix))
{ {

View File

@@ -9,13 +9,12 @@ namespace NadekoBot.Modules.Administration;
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class ProtectionCommands : NadekoSubmodule<ProtectionService> public partial class ProtectionCommands : NadekoSubmodule<ProtectionService>
{ {
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task AntiAlt() public async partial Task AntiAlt()
{ {
if (await _service.TryStopAntiAlt(ctx.Guild.Id)) if (await _service.TryStopAntiAlt(ctx.Guild.Id))
{ {
@@ -26,11 +25,10 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.protection_not_running("Anti-Alt")); await ReplyConfirmLocalizedAsync(strs.protection_not_running("Anti-Alt"));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task AntiAlt(StoopidTime minAge, PunishmentAction action, [Leftover] StoopidTime punishTime = null) public async partial Task AntiAlt(StoopidTime minAge, PunishmentAction action, [Leftover] StoopidTime punishTime = null)
{ {
var minAgeMinutes = (int)minAge.Time.TotalMinutes; var minAgeMinutes = (int)minAge.Time.TotalMinutes;
var punishTimeMinutes = (int?)punishTime?.Time.TotalMinutes ?? 0; var punishTimeMinutes = (int?)punishTime?.Time.TotalMinutes ?? 0;
@@ -46,11 +44,10 @@ public partial class Administration
await ctx.OkAsync(); await ctx.OkAsync();
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task AntiAlt(StoopidTime minAge, PunishmentAction action, [Leftover] IRole role) public async partial Task AntiAlt(StoopidTime minAge, PunishmentAction action, [Leftover] IRole role)
{ {
var minAgeMinutes = (int)minAge.Time.TotalMinutes; var minAgeMinutes = (int)minAge.Time.TotalMinutes;
@@ -62,35 +59,32 @@ public partial class Administration
await ctx.OkAsync(); await ctx.OkAsync();
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public Task AntiRaid() public partial Task AntiRaid()
{ {
if (_service.TryStopAntiRaid(ctx.Guild.Id)) if (_service.TryStopAntiRaid(ctx.Guild.Id))
return ReplyConfirmLocalizedAsync(strs.prot_disable("Anti-Raid")); return ReplyConfirmLocalizedAsync(strs.prot_disable("Anti-Raid"));
return ReplyPendingLocalizedAsync(strs.protection_not_running("Anti-Raid")); return ReplyPendingLocalizedAsync(strs.protection_not_running("Anti-Raid"));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[Priority(1)] [Priority(1)]
public Task AntiRaid( public partial Task AntiRaid(
int userThreshold, int userThreshold,
int seconds, int seconds,
PunishmentAction action, PunishmentAction action,
[Leftover] StoopidTime punishTime) [Leftover] StoopidTime punishTime)
=> InternalAntiRaid(userThreshold, seconds, action, punishTime); => InternalAntiRaid(userThreshold, seconds, action, punishTime);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[Priority(2)] [Priority(2)]
public Task AntiRaid(int userThreshold, int seconds, PunishmentAction action) public partial Task AntiRaid(int userThreshold, int seconds, PunishmentAction action)
=> InternalAntiRaid(userThreshold, seconds, action); => InternalAntiRaid(userThreshold, seconds, action);
private async Task InternalAntiRaid( private async Task InternalAntiRaid(
@@ -133,23 +127,21 @@ public partial class Administration
$"{ctx.User.Mention} {GetAntiRaidString(stats)}"); $"{ctx.User.Mention} {GetAntiRaidString(stats)}");
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public Task AntiSpam() public partial Task AntiSpam()
{ {
if (_service.TryStopAntiSpam(ctx.Guild.Id)) if (_service.TryStopAntiSpam(ctx.Guild.Id))
return ReplyConfirmLocalizedAsync(strs.prot_disable("Anti-Spam")); return ReplyConfirmLocalizedAsync(strs.prot_disable("Anti-Spam"));
return ReplyPendingLocalizedAsync(strs.protection_not_running("Anti-Spam")); return ReplyPendingLocalizedAsync(strs.protection_not_running("Anti-Spam"));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[Priority(0)] [Priority(0)]
public Task AntiSpam(int messageCount, PunishmentAction action, [Leftover] IRole role) public partial Task AntiSpam(int messageCount, PunishmentAction action, [Leftover] IRole role)
{ {
if (action != PunishmentAction.AddRole) if (action != PunishmentAction.AddRole)
return Task.CompletedTask; return Task.CompletedTask;
@@ -157,23 +149,21 @@ public partial class Administration
return InternalAntiSpam(messageCount, action, null, role); return InternalAntiSpam(messageCount, action, null, role);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[Priority(1)] [Priority(1)]
public Task AntiSpam(int messageCount, PunishmentAction action, [Leftover] StoopidTime punishTime) public partial Task AntiSpam(int messageCount, PunishmentAction action, [Leftover] StoopidTime punishTime)
=> InternalAntiSpam(messageCount, action, punishTime); => InternalAntiSpam(messageCount, action, punishTime);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[Priority(2)] [Priority(2)]
public Task AntiSpam(int messageCount, PunishmentAction action) public partial Task AntiSpam(int messageCount, PunishmentAction action)
=> InternalAntiSpam(messageCount, action); => InternalAntiSpam(messageCount, action);
public async Task InternalAntiSpam( private async Task InternalAntiSpam(
int messageCount, int messageCount,
PunishmentAction action, PunishmentAction action,
StoopidTime timeData = null, StoopidTime timeData = null,
@@ -196,11 +186,10 @@ public partial class Administration
$"{ctx.User.Mention} {GetAntiSpamString(stats)}"); $"{ctx.User.Mention} {GetAntiSpamString(stats)}");
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task AntispamIgnore() public async partial Task AntispamIgnore()
{ {
var added = await _service.AntiSpamIgnoreAsync(ctx.Guild.Id, ctx.Channel.Id); var added = await _service.AntiSpamIgnoreAsync(ctx.Guild.Id, ctx.Channel.Id);
@@ -216,10 +205,9 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.spam_not_ignore("Anti-Spam")); await ReplyConfirmLocalizedAsync(strs.spam_not_ignore("Anti-Spam"));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task AntiList() public async partial Task AntiList()
{ {
var (spam, raid, alt) = _service.GetAntiStats(ctx.Guild.Id); var (spam, raid, alt) = _service.GetAntiStats(ctx.Guild.Id);

View File

@@ -6,15 +6,14 @@ namespace NadekoBot.Modules.Administration;
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class PruneCommands : NadekoSubmodule<PruneService> public partial class PruneCommands : NadekoSubmodule<PruneService>
{ {
private static readonly TimeSpan twoWeeks = TimeSpan.FromDays(14); private static readonly TimeSpan twoWeeks = TimeSpan.FromDays(14);
//delets her own messages, no perm required //delets her own messages, no perm required
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Prune(string parameter = null) public async partial Task Prune(string parameter = null)
{ {
var user = await ctx.Guild.GetCurrentUserAsync(); var user = await ctx.Guild.GetCurrentUserAsync();
@@ -26,13 +25,12 @@ public partial class Administration
} }
// prune x // prune x
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(ChannelPerm.ManageMessages)] [UserPerm(ChannelPerm.ManageMessages)]
[BotPerm(ChannelPerm.ManageMessages)] [BotPerm(ChannelPerm.ManageMessages)]
[Priority(1)] [Priority(1)]
public async Task Prune(int count, string parameter = null) public async partial Task Prune(int count, string parameter = null)
{ {
count++; count++;
if (count < 1) if (count < 1)
@@ -47,23 +45,21 @@ public partial class Administration
} }
//prune @user [x] //prune @user [x]
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(ChannelPerm.ManageMessages)] [UserPerm(ChannelPerm.ManageMessages)]
[BotPerm(ChannelPerm.ManageMessages)] [BotPerm(ChannelPerm.ManageMessages)]
[Priority(0)] [Priority(0)]
public Task Prune(IGuildUser user, int count = 100, string parameter = null) public partial Task Prune(IGuildUser user, int count = 100, string parameter = null)
=> Prune(user.Id, count, parameter); => Prune(user.Id, count, parameter);
//prune userid [x] //prune userid [x]
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(ChannelPerm.ManageMessages)] [UserPerm(ChannelPerm.ManageMessages)]
[BotPerm(ChannelPerm.ManageMessages)] [BotPerm(ChannelPerm.ManageMessages)]
[Priority(0)] [Priority(0)]
public async Task Prune(ulong userId, int count = 100, string parameter = null) public async partial Task Prune(ulong userId, int count = 100, string parameter = null)
{ {
if (userId == ctx.User.Id) if (userId == ctx.User.Id)
count++; count++;

View File

@@ -9,7 +9,7 @@ namespace NadekoBot.Modules.Administration;
public partial class Administration public partial class Administration
{ {
public class RoleCommands : NadekoSubmodule<RoleCommandsService> public partial class RoleCommands : NadekoSubmodule<RoleCommandsService>
{ {
public enum Exclude { Excl } public enum Exclude { Excl }
@@ -88,52 +88,47 @@ public partial class Administration
await ReplyErrorLocalizedAsync(strs.reaction_roles_full); await ReplyErrorLocalizedAsync(strs.reaction_roles_full);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[NoPublicBot] [NoPublicBot]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
[Priority(0)] [Priority(0)]
public Task ReactionRoles(ulong messageId, params string[] input) public partial Task ReactionRoles(ulong messageId, params string[] input)
=> InternalReactionRoles(false, messageId, input); => InternalReactionRoles(false, messageId, input);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[NoPublicBot] [NoPublicBot]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
[Priority(1)] [Priority(1)]
public Task ReactionRoles(ulong messageId, Exclude _, params string[] input) public partial Task ReactionRoles(ulong messageId, Exclude _, params string[] input)
=> InternalReactionRoles(true, messageId, input); => InternalReactionRoles(true, messageId, input);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[NoPublicBot] [NoPublicBot]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
[Priority(0)] [Priority(0)]
public Task ReactionRoles(params string[] input) public partial Task ReactionRoles(params string[] input)
=> InternalReactionRoles(false, null, input); => InternalReactionRoles(false, null, input);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[NoPublicBot] [NoPublicBot]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
[Priority(1)] [Priority(1)]
public Task ReactionRoles(Exclude _, params string[] input) public partial Task ReactionRoles(Exclude _, params string[] input)
=> InternalReactionRoles(true, null, input); => InternalReactionRoles(true, null, input);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[NoPublicBot] [NoPublicBot]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
public async Task ReactionRolesList() public async partial Task ReactionRolesList()
{ {
var embed = _eb.Create().WithOkColor(); var embed = _eb.Create().WithOkColor();
if (!_service.Get(ctx.Guild.Id, out var rrs) || !rrs.Any()) if (!_service.Get(ctx.Guild.Id, out var rrs) || !rrs.Any())
@@ -157,12 +152,11 @@ public partial class Administration
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[NoPublicBot] [NoPublicBot]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
public async Task ReactionRolesRemove(int index) public async partial Task ReactionRolesRemove(int index)
{ {
if (index < 1 || !_service.Get(ctx.Guild.Id, out var rrs) || !rrs.Any() || rrs.Count < index) if (index < 1 || !_service.Get(ctx.Guild.Id, out var rrs) || !rrs.Any() || rrs.Count < index)
return; return;
@@ -172,12 +166,11 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.reaction_role_removed(index + 1)); await ReplyConfirmLocalizedAsync(strs.reaction_role_removed(index + 1));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
public async Task SetRole(IGuildUser targetUser, [Leftover] IRole roleToAdd) public async partial Task SetRole(IGuildUser targetUser, [Leftover] IRole roleToAdd)
{ {
var runnerUser = (IGuildUser)ctx.User; var runnerUser = (IGuildUser)ctx.User;
var runnerMaxRolePosition = runnerUser.GetRoles().Max(x => x.Position); var runnerMaxRolePosition = runnerUser.GetRoles().Max(x => x.Position);
@@ -197,12 +190,11 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
public async Task RemoveRole(IGuildUser targetUser, [Leftover] IRole roleToRemove) public async partial Task RemoveRole(IGuildUser targetUser, [Leftover] IRole roleToRemove)
{ {
var runnerUser = (IGuildUser)ctx.User; var runnerUser = (IGuildUser)ctx.User;
if (ctx.User.Id != runnerUser.Guild.OwnerId if (ctx.User.Id != runnerUser.Guild.OwnerId
@@ -220,12 +212,11 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
public async Task RenameRole(IRole roleToEdit, [Leftover] string newname) public async partial Task RenameRole(IRole roleToEdit, [Leftover] string newname)
{ {
var guser = (IGuildUser)ctx.User; var guser = (IGuildUser)ctx.User;
if (ctx.User.Id != guser.Guild.OwnerId && guser.GetRoles().Max(x => x.Position) <= roleToEdit.Position) if (ctx.User.Id != guser.Guild.OwnerId && guser.GetRoles().Max(x => x.Position) <= roleToEdit.Position)
@@ -247,12 +238,11 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
public async Task RemoveAllRoles([Leftover] IGuildUser user) public async partial Task RemoveAllRoles([Leftover] IGuildUser user)
{ {
var guser = (IGuildUser)ctx.User; var guser = (IGuildUser)ctx.User;
@@ -273,12 +263,11 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
public async Task CreateRole([Leftover] string roleName = null) public async partial Task CreateRole([Leftover] string roleName = null)
{ {
if (string.IsNullOrWhiteSpace(roleName)) if (string.IsNullOrWhiteSpace(roleName))
return; return;
@@ -287,12 +276,11 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.cr(Format.Bold(r.Name))); await ReplyConfirmLocalizedAsync(strs.cr(Format.Bold(r.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
public async Task DeleteRole([Leftover] IRole role) public async partial Task DeleteRole([Leftover] IRole role)
{ {
var guser = (IGuildUser)ctx.User; var guser = (IGuildUser)ctx.User;
if (ctx.User.Id != guser.Guild.OwnerId && guser.GetRoles().Max(x => x.Position) <= role.Position) if (ctx.User.Id != guser.Guild.OwnerId && guser.GetRoles().Max(x => x.Position) <= role.Position)
@@ -302,12 +290,11 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.dr(Format.Bold(role.Name))); await ReplyConfirmLocalizedAsync(strs.dr(Format.Bold(role.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
public async Task RoleHoist(IRole role) public async partial Task RoleHoist(IRole role)
{ {
var newHoisted = !role.IsHoisted; var newHoisted = !role.IsHoisted;
await role.ModifyAsync(r => r.Hoist = newHoisted); await role.ModifyAsync(r => r.Hoist = newHoisted);
@@ -317,20 +304,18 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.rolehoist_disabled(Format.Bold(role.Name))); await ReplyConfirmLocalizedAsync(strs.rolehoist_disabled(Format.Bold(role.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(1)] [Priority(1)]
public async Task RoleColor([Leftover] IRole role) public async partial Task RoleColor([Leftover] IRole role)
=> await SendConfirmAsync("Role Color", role.Color.RawValue.ToString("x6")); => await SendConfirmAsync("Role Color", role.Color.RawValue.ToString("x6"));
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
[Priority(0)] [Priority(0)]
public async Task RoleColor(Color color, [Leftover] IRole role) public async partial Task RoleColor(Color color, [Leftover] IRole role)
{ {
try try
{ {

View File

@@ -7,7 +7,7 @@ namespace NadekoBot.Modules.Administration;
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class SelfCommands : NadekoSubmodule<SelfService> public partial class SelfCommands : NadekoSubmodule<SelfService>
{ {
public enum SettableUserStatus public enum SettableUserStatus
{ {
@@ -28,12 +28,11 @@ public partial class Administration
_coord = coord; _coord = coord;
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[OwnerOnly] [OwnerOnly]
public async Task StartupCommandAdd([Leftover] string cmdText) public async partial Task StartupCommandAdd([Leftover] string cmdText)
{ {
if (cmdText.StartsWith(Prefix + "die", StringComparison.InvariantCulture)) if (cmdText.StartsWith(Prefix + "die", StringComparison.InvariantCulture))
return; return;
@@ -62,12 +61,11 @@ public partial class Administration
.AddField(GetText(strs.command_text), cmdText)); .AddField(GetText(strs.command_text), cmdText));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[OwnerOnly] [OwnerOnly]
public async Task AutoCommandAdd(int interval, [Leftover] string cmdText) public async partial Task AutoCommandAdd(int interval, [Leftover] string cmdText)
{ {
if (cmdText.StartsWith(Prefix + "die", StringComparison.InvariantCulture)) if (cmdText.StartsWith(Prefix + "die", StringComparison.InvariantCulture))
return; return;
@@ -92,11 +90,10 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.autocmd_add(Format.Code(Format.Sanitize(cmdText)), cmd.Interval)); await ReplyConfirmLocalizedAsync(strs.autocmd_add(Format.Code(Format.Sanitize(cmdText)), cmd.Interval));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[OwnerOnly] [OwnerOnly]
public async Task StartupCommandsList(int page = 1) public async partial Task StartupCommandsList(int page = 1)
{ {
if (page-- < 1) if (page-- < 1)
return; return;
@@ -121,11 +118,10 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[OwnerOnly] [OwnerOnly]
public async Task AutoCommandsList(int page = 1) public async partial Task AutoCommandsList(int page = 1)
{ {
if (page-- < 1) if (page-- < 1)
return; return;
@@ -153,10 +149,9 @@ public partial class Administration
private string GetIntervalText(int interval) private string GetIntervalText(int interval)
=> $"[{GetText(strs.interval)}]: {interval}"; => $"[{GetText(strs.interval)}]: {interval}";
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task Wait(int miliseconds) public async partial Task Wait(int miliseconds)
{ {
if (miliseconds <= 0) if (miliseconds <= 0)
return; return;
@@ -171,12 +166,11 @@ public partial class Administration
await Task.Delay(miliseconds); await Task.Delay(miliseconds);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[OwnerOnly] [OwnerOnly]
public async Task AutoCommandRemove([Leftover] int index) public async partial Task AutoCommandRemove([Leftover] int index)
{ {
if (!_service.RemoveAutoCommand(--index, out _)) if (!_service.RemoveAutoCommand(--index, out _))
{ {
@@ -187,11 +181,10 @@ public partial class Administration
await ctx.OkAsync(); await ctx.OkAsync();
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[OwnerOnly] [OwnerOnly]
public async Task StartupCommandRemove([Leftover] int index) public async partial Task StartupCommandRemove([Leftover] int index)
{ {
if (!_service.RemoveStartupCommand(--index, out _)) if (!_service.RemoveStartupCommand(--index, out _))
await ReplyErrorLocalizedAsync(strs.scrm_fail); await ReplyErrorLocalizedAsync(strs.scrm_fail);
@@ -199,22 +192,20 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.scrm); await ReplyConfirmLocalizedAsync(strs.scrm);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[OwnerOnly] [OwnerOnly]
public async Task StartupCommandsClear() public async partial Task StartupCommandsClear()
{ {
_service.ClearStartupCommands(); _service.ClearStartupCommands();
await ReplyConfirmLocalizedAsync(strs.startcmds_cleared); await ReplyConfirmLocalizedAsync(strs.startcmds_cleared);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task ForwardMessages() public async partial Task ForwardMessages()
{ {
var enabled = _service.ForwardMessages(); var enabled = _service.ForwardMessages();
@@ -224,10 +215,9 @@ public partial class Administration
await ReplyPendingLocalizedAsync(strs.fwdm_stop); await ReplyPendingLocalizedAsync(strs.fwdm_stop);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task ForwardToAll() public async partial Task ForwardToAll()
{ {
var enabled = _service.ForwardToAll(); var enabled = _service.ForwardToAll();
@@ -237,9 +227,8 @@ public partial class Administration
await ReplyPendingLocalizedAsync(strs.fwall_stop); await ReplyPendingLocalizedAsync(strs.fwall_stop);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task ShardStats(int page = 1)
public async Task ShardStats(int page = 1)
{ {
if (--page < 0) if (--page < 0)
return; return;
@@ -290,10 +279,9 @@ public partial class Administration
}; };
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task RestartShard(int shardId) public async partial Task RestartShard(int shardId)
{ {
var success = _coord.RestartShard(shardId); var success = _coord.RestartShard(shardId);
if (success) if (success)
@@ -302,17 +290,15 @@ public partial class Administration
await ReplyErrorLocalizedAsync(strs.no_shard_id); await ReplyErrorLocalizedAsync(strs.no_shard_id);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task Leave([Leftover] string guildStr) public partial Task Leave([Leftover] string guildStr)
=> _service.LeaveGuild(guildStr); => _service.LeaveGuild(guildStr);
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task Die(bool graceful = false) public async partial Task Die(bool graceful = false)
{ {
try try
{ {
@@ -327,10 +313,9 @@ public partial class Administration
_coord.Die(graceful); _coord.Die(graceful);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task Restart() public async partial Task Restart()
{ {
var success = _coord.RestartBot(); var success = _coord.RestartBot();
if (!success) if (!success)
@@ -343,10 +328,9 @@ public partial class Administration
catch { } catch { }
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task SetName([Leftover] string newName) public async partial Task SetName([Leftover] string newName)
{ {
if (string.IsNullOrWhiteSpace(newName)) if (string.IsNullOrWhiteSpace(newName))
return; return;
@@ -363,12 +347,11 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.bot_name(Format.Bold(newName))); await ReplyConfirmLocalizedAsync(strs.bot_name(Format.Bold(newName)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[UserPerm(GuildPerm.ManageNicknames)] [UserPerm(GuildPerm.ManageNicknames)]
[BotPerm(GuildPerm.ChangeNickname)] [BotPerm(GuildPerm.ChangeNickname)]
[Priority(0)] [Priority(0)]
public async Task SetNick([Leftover] string newNick = null) public async partial Task SetNick([Leftover] string newNick = null)
{ {
if (string.IsNullOrWhiteSpace(newNick)) if (string.IsNullOrWhiteSpace(newNick))
return; return;
@@ -378,12 +361,11 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.bot_nick(Format.Bold(newNick) ?? "-")); await ReplyConfirmLocalizedAsync(strs.bot_nick(Format.Bold(newNick) ?? "-"));
} }
[NadekoCommand] [Cmd]
[Aliases]
[BotPerm(GuildPerm.ManageNicknames)] [BotPerm(GuildPerm.ManageNicknames)]
[UserPerm(GuildPerm.ManageNicknames)] [UserPerm(GuildPerm.ManageNicknames)]
[Priority(1)] [Priority(1)]
public async Task SetNick(IGuildUser gu, [Leftover] string newNick = null) public async partial Task SetNick(IGuildUser gu, [Leftover] string newNick = null)
{ {
var sg = (SocketGuild)ctx.Guild; var sg = (SocketGuild)ctx.Guild;
if (sg.OwnerId == gu.Id if (sg.OwnerId == gu.Id
@@ -398,30 +380,27 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.user_nick(Format.Bold(gu.ToString()), Format.Bold(newNick) ?? "-")); await ReplyConfirmLocalizedAsync(strs.user_nick(Format.Bold(gu.ToString()), Format.Bold(newNick) ?? "-"));
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task SetStatus([Leftover] SettableUserStatus status) public async partial Task SetStatus([Leftover] SettableUserStatus status)
{ {
await _client.SetStatusAsync(SettableUserStatusToUserStatus(status)); await _client.SetStatusAsync(SettableUserStatusToUserStatus(status));
await ReplyConfirmLocalizedAsync(strs.bot_status(Format.Bold(status.ToString()))); await ReplyConfirmLocalizedAsync(strs.bot_status(Format.Bold(status.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task SetAvatar([Leftover] string img = null) public async partial Task SetAvatar([Leftover] string img = null)
{ {
var success = await _service.SetAvatar(img); var success = await _service.SetAvatar(img);
if (success) await ReplyConfirmLocalizedAsync(strs.set_avatar); if (success) await ReplyConfirmLocalizedAsync(strs.set_avatar);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task SetGame(ActivityType type, [Leftover] string game = null) public async partial Task SetGame(ActivityType type, [Leftover] string game = null)
{ {
var rep = new ReplacementBuilder().WithDefault(Context).Build(); var rep = new ReplacementBuilder().WithDefault(Context).Build();
@@ -430,10 +409,9 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.set_game); await ReplyConfirmLocalizedAsync(strs.set_game);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task SetStream(string url, [Leftover] string name = null) public async partial Task SetStream(string url, [Leftover] string name = null)
{ {
name ??= ""; name ??= "";
@@ -442,10 +420,9 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.set_stream); await ReplyConfirmLocalizedAsync(strs.set_stream);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task Send(string where, [Leftover] SmartText text = null) public async partial Task Send(string where, [Leftover] SmartText text = null)
{ {
var ids = where.Split('|'); var ids = where.Split('|');
if (ids.Length != 2) if (ids.Length != 2)
@@ -489,28 +466,25 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.message_sent); await ReplyConfirmLocalizedAsync(strs.message_sent);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task ImagesReload() public async partial Task ImagesReload()
{ {
await _service.ReloadImagesAsync(); await _service.ReloadImagesAsync();
await ReplyConfirmLocalizedAsync(strs.images_loading); await ReplyConfirmLocalizedAsync(strs.images_loading);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task StringsReload() public async partial Task StringsReload()
{ {
_strings.Reload(); _strings.Reload();
await ReplyConfirmLocalizedAsync(strs.bot_strings_reloaded); await ReplyConfirmLocalizedAsync(strs.bot_strings_reloaded);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task CoordReload() public async partial Task CoordReload()
{ {
await _coord.Reload(); await _coord.Reload();
await ctx.OkAsync(); await ctx.OkAsync();

View File

@@ -7,14 +7,13 @@ namespace NadekoBot.Modules.Administration;
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class SelfAssignedRolesCommands : NadekoSubmodule<SelfAssignedRolesService> public partial class SelfAssignedRolesCommands : NadekoSubmodule<SelfAssignedRolesService>
{ {
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
[BotPerm(GuildPerm.ManageMessages)] [BotPerm(GuildPerm.ManageMessages)]
public async Task AdSarm() public async partial Task AdSarm()
{ {
var newVal = _service.ToggleAdSarm(ctx.Guild.Id); var newVal = _service.ToggleAdSarm(ctx.Guild.Id);
@@ -24,22 +23,20 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.adsarm_disable(Prefix)); await ReplyConfirmLocalizedAsync(strs.adsarm_disable(Prefix));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
[Priority(1)] [Priority(1)]
public Task Asar([Leftover] IRole role) public partial Task Asar([Leftover] IRole role)
=> Asar(0, role); => Asar(0, role);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
[Priority(0)] [Priority(0)]
public async Task Asar(int group, [Leftover] IRole role) public async partial Task Asar(int group, [Leftover] IRole role)
{ {
var guser = (IGuildUser)ctx.User; var guser = (IGuildUser)ctx.User;
if (ctx.User.Id != guser.Guild.OwnerId && guser.GetRoles().Max(x => x.Position) <= role.Position) if (ctx.User.Id != guser.Guild.OwnerId && guser.GetRoles().Max(x => x.Position) <= role.Position)
@@ -54,13 +51,12 @@ public partial class Administration
await ReplyErrorLocalizedAsync(strs.role_in_list(Format.Bold(role.Name))); await ReplyErrorLocalizedAsync(strs.role_in_list(Format.Bold(role.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
[Priority(0)] [Priority(0)]
public async Task Sargn(int group, [Leftover] string name = null) public async partial Task Sargn(int group, [Leftover] string name = null)
{ {
var guser = (IGuildUser)ctx.User; var guser = (IGuildUser)ctx.User;
@@ -73,11 +69,10 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.group_name_removed(Format.Bold(group.ToString()))); await ReplyConfirmLocalizedAsync(strs.group_name_removed(Format.Bold(group.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
public async Task Rsar([Leftover] IRole role) public async partial Task Rsar([Leftover] IRole role)
{ {
var guser = (IGuildUser)ctx.User; var guser = (IGuildUser)ctx.User;
if (ctx.User.Id != guser.Guild.OwnerId && guser.GetRoles().Max(x => x.Position) <= role.Position) if (ctx.User.Id != guser.Guild.OwnerId && guser.GetRoles().Max(x => x.Position) <= role.Position)
@@ -90,10 +85,9 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.self_assign_rem(Format.Bold(role.Name))); await ReplyConfirmLocalizedAsync(strs.self_assign_rem(Format.Bold(role.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Lsar(int page = 1) public async partial Task Lsar(int page = 1)
{ {
if (--page < 0) if (--page < 0)
return; return;
@@ -147,12 +141,11 @@ public partial class Administration
20); 20);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
public async Task Togglexclsar() public async partial Task Togglexclsar()
{ {
var areExclusive = _service.ToggleEsar(ctx.Guild.Id); var areExclusive = _service.ToggleEsar(ctx.Guild.Id);
if (areExclusive) if (areExclusive)
@@ -161,12 +154,11 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.self_assign_no_excl); await ReplyConfirmLocalizedAsync(strs.self_assign_no_excl);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
public async Task RoleLevelReq(int level, [Leftover] IRole role) public async partial Task RoleLevelReq(int level, [Leftover] IRole role)
{ {
if (level < 0) if (level < 0)
return; return;
@@ -183,23 +175,22 @@ public partial class Administration
Format.Bold(level.ToString()))); Format.Bold(level.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Iam([Leftover] IRole role) public async partial Task Iam([Leftover] IRole role)
{ {
var guildUser = (IGuildUser)ctx.User; var guildUser = (IGuildUser)ctx.User;
var (result, autoDelete, extra) = await _service.Assign(guildUser, role); var (result, autoDelete, extra) = await _service.Assign(guildUser, role);
IUserMessage msg; IUserMessage msg;
if (result == SelfAssignedRolesService.AssignResult.Err_Not_Assignable) if (result == SelfAssignedRolesService.AssignResult.ErrNotAssignable)
msg = await ReplyErrorLocalizedAsync(strs.self_assign_not); msg = await ReplyErrorLocalizedAsync(strs.self_assign_not);
else if (result == SelfAssignedRolesService.AssignResult.Err_Lvl_Req) else if (result == SelfAssignedRolesService.AssignResult.ErrLvlReq)
msg = await ReplyErrorLocalizedAsync(strs.self_assign_not_level(Format.Bold(extra.ToString()))); msg = await ReplyErrorLocalizedAsync(strs.self_assign_not_level(Format.Bold(extra.ToString())));
else if (result == SelfAssignedRolesService.AssignResult.Err_Already_Have) else if (result == SelfAssignedRolesService.AssignResult.ErrAlreadyHave)
msg = await ReplyErrorLocalizedAsync(strs.self_assign_already(Format.Bold(role.Name))); msg = await ReplyErrorLocalizedAsync(strs.self_assign_already(Format.Bold(role.Name)));
else if (result == SelfAssignedRolesService.AssignResult.Err_Not_Perms) else if (result == SelfAssignedRolesService.AssignResult.ErrNotPerms)
msg = await ReplyErrorLocalizedAsync(strs.self_assign_perms); msg = await ReplyErrorLocalizedAsync(strs.self_assign_perms);
else else
msg = await ReplyConfirmLocalizedAsync(strs.self_assign_success(Format.Bold(role.Name))); msg = await ReplyConfirmLocalizedAsync(strs.self_assign_success(Format.Bold(role.Name)));
@@ -211,21 +202,20 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Iamnot([Leftover] IRole role) public async partial Task Iamnot([Leftover] IRole role)
{ {
var guildUser = (IGuildUser)ctx.User; var guildUser = (IGuildUser)ctx.User;
var (result, autoDelete) = await _service.Remove(guildUser, role); var (result, autoDelete) = await _service.Remove(guildUser, role);
IUserMessage msg; IUserMessage msg;
if (result == SelfAssignedRolesService.RemoveResult.Err_Not_Assignable) if (result == SelfAssignedRolesService.RemoveResult.ErrNotAssignable)
msg = await ReplyErrorLocalizedAsync(strs.self_assign_not); msg = await ReplyErrorLocalizedAsync(strs.self_assign_not);
else if (result == SelfAssignedRolesService.RemoveResult.Err_Not_Have) else if (result == SelfAssignedRolesService.RemoveResult.ErrNotHave)
msg = await ReplyErrorLocalizedAsync(strs.self_assign_not_have(Format.Bold(role.Name))); msg = await ReplyErrorLocalizedAsync(strs.self_assign_not_have(Format.Bold(role.Name)));
else if (result == SelfAssignedRolesService.RemoveResult.Err_Not_Perms) else if (result == SelfAssignedRolesService.RemoveResult.ErrNotPerms)
msg = await ReplyErrorLocalizedAsync(strs.self_assign_perms); msg = await ReplyErrorLocalizedAsync(strs.self_assign_perms);
else else
msg = await ReplyConfirmLocalizedAsync(strs.self_assign_remove(Format.Bold(role.Name))); msg = await ReplyConfirmLocalizedAsync(strs.self_assign_remove(Format.Bold(role.Name)));

View File

@@ -11,18 +11,18 @@ public class SelfAssignedRolesService : INService
public enum AssignResult public enum AssignResult
{ {
Assigned, // successfully removed Assigned, // successfully removed
Err_Not_Assignable, // not assignable (error) ErrNotAssignable, // not assignable (error)
Err_Already_Have, // you already have that role (error) ErrAlreadyHave, // you already have that role (error)
Err_Not_Perms, // bot doesn't have perms (error) ErrNotPerms, // bot doesn't have perms (error)
Err_Lvl_Req // you are not required level (error) ErrLvlReq // you are not required level (error)
} }
public enum RemoveResult public enum RemoveResult
{ {
Removed, // successfully removed Removed, // successfully removed
Err_Not_Assignable, // not assignable (error) ErrNotAssignable, // not assignable (error)
Err_Not_Have, // you don't have a role you want to remove (error) ErrNotHave, // you don't have a role you want to remove (error)
Err_Not_Perms // bot doesn't have perms (error) ErrNotPerms // bot doesn't have perms (error)
} }
private readonly DbService _db; private readonly DbService _db;
@@ -64,10 +64,10 @@ public class SelfAssignedRolesService : INService
var theRoleYouWant = roles.FirstOrDefault(r => r.RoleId == role.Id); var theRoleYouWant = roles.FirstOrDefault(r => r.RoleId == role.Id);
if (theRoleYouWant is null) if (theRoleYouWant is null)
return (AssignResult.Err_Not_Assignable, autoDelete, null); return (AssignResult.ErrNotAssignable, autoDelete, null);
if (theRoleYouWant.LevelRequirement > userLevelData.Level) if (theRoleYouWant.LevelRequirement > userLevelData.Level)
return (AssignResult.Err_Lvl_Req, autoDelete, theRoleYouWant.LevelRequirement); return (AssignResult.ErrLvlReq, autoDelete, theRoleYouWant.LevelRequirement);
if (guildUser.RoleIds.Contains(role.Id)) return (AssignResult.Err_Already_Have, autoDelete, null); if (guildUser.RoleIds.Contains(role.Id)) return (AssignResult.ErrAlreadyHave, autoDelete, null);
var roleIds = roles.Where(x => x.Group == theRoleYouWant.Group).Select(x => x.RoleId).ToArray(); var roleIds = roles.Where(x => x.Group == theRoleYouWant.Group).Select(x => x.RoleId).ToArray();
if (exclusive) if (exclusive)
@@ -96,7 +96,7 @@ public class SelfAssignedRolesService : INService
} }
catch (Exception ex) catch (Exception ex)
{ {
return (AssignResult.Err_Not_Perms, autoDelete, ex); return (AssignResult.ErrNotPerms, autoDelete, ex);
} }
return (AssignResult.Assigned, autoDelete, null); return (AssignResult.Assigned, autoDelete, null);
@@ -135,15 +135,15 @@ public class SelfAssignedRolesService : INService
var (autoDelete, _, roles) = GetAdAndRoles(guildUser.Guild.Id); var (autoDelete, _, roles) = GetAdAndRoles(guildUser.Guild.Id);
if (roles.FirstOrDefault(r => r.RoleId == role.Id) is null) if (roles.FirstOrDefault(r => r.RoleId == role.Id) is null)
return (RemoveResult.Err_Not_Assignable, autoDelete); return (RemoveResult.ErrNotAssignable, autoDelete);
if (!guildUser.RoleIds.Contains(role.Id)) return (RemoveResult.Err_Not_Have, autoDelete); if (!guildUser.RoleIds.Contains(role.Id)) return (RemoveResult.ErrNotHave, autoDelete);
try try
{ {
await guildUser.RemoveRoleAsync(role); await guildUser.RemoveRoleAsync(role);
} }
catch (Exception) catch (Exception)
{ {
return (RemoveResult.Err_Not_Perms, autoDelete); return (RemoveResult.ErrNotPerms, autoDelete);
} }
return (RemoveResult.Removed, autoDelete); return (RemoveResult.Removed, autoDelete);

View File

@@ -118,11 +118,9 @@ public sealed class ImageOnlyChannelService : IEarlyBehavior
if (user.GetRoles().Max(x => x.Position) >= botUser.GetRoles().Max(x => x.Position)) if (user.GetRoles().Max(x => x.Position) >= botUser.GetRoles().Max(x => x.Position))
return false; return false;
// can't modify channel perms if not admin apparently if (!botUser.GetPermissions(tch).ManageChannel)
if (!botUser.GuildPermissions.ManageGuild)
{ {
ToggleImageOnlyChannel(tch.GuildId, tch.Id, true); ToggleImageOnlyChannel(tch.GuildId, tch.Id, true);
;
return false; return false;
} }
@@ -142,7 +140,7 @@ public sealed class ImageOnlyChannelService : IEarlyBehavior
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex, "Error deleting message {MessageId} in image-only channel {ChannelId}.", msg.Id, tch.Id); Log.Error(ex, "Error deleting message {MessageId} in image-only channel {ChannelId}", msg.Id, tch.Id);
} }
return true; return true;

View File

@@ -6,12 +6,11 @@ namespace NadekoBot.Modules.Administration;
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class TimeZoneCommands : NadekoSubmodule<GuildTimezoneService> public partial class TimeZoneCommands : NadekoSubmodule<GuildTimezoneService>
{ {
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Timezones(int page = 1) public async partial Task Timezones(int page = 1)
{ {
page--; page--;
@@ -47,17 +46,15 @@ public partial class Administration
timezonesPerPage); timezonesPerPage);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Timezone() public async partial Task Timezone()
=> await ReplyConfirmLocalizedAsync(strs.timezone_guild(_service.GetTimeZoneOrUtc(ctx.Guild.Id))); => await ReplyConfirmLocalizedAsync(strs.timezone_guild(_service.GetTimeZoneOrUtc(ctx.Guild.Id)));
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task Timezone([Leftover] string id) public async partial Task Timezone([Leftover] string id)
{ {
TimeZoneInfo tz; TimeZoneInfo tz;
try { tz = TimeZoneInfo.FindSystemTimeZoneById(id); } try { tz = TimeZoneInfo.FindSystemTimeZoneById(id); }

View File

@@ -11,7 +11,7 @@ namespace NadekoBot.Modules.Administration;
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class UserPunishCommands : NadekoSubmodule<UserPunishService> public partial class UserPunishCommands : NadekoSubmodule<UserPunishService>
{ {
public enum AddRole public enum AddRole
{ {
@@ -48,18 +48,16 @@ public partial class Administration
return true; return true;
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
public Task Warn(IGuildUser user, [Leftover] string reason = null) public partial Task Warn(IGuildUser user, [Leftover] string reason = null)
=> Warn(1, user, reason); => Warn(1, user, reason);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
public async Task Warn(int weight, IGuildUser user, [Leftover] string reason = null) public async partial Task Warn(int weight, IGuildUser user, [Leftover] string reason = null)
{ {
if (weight <= 0) if (weight <= 0)
return; return;
@@ -109,13 +107,12 @@ public partial class Administration
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[NadekoOptions(typeof(WarnExpireOptions))] [NadekoOptions(typeof(WarnExpireOptions))]
[Priority(1)] [Priority(1)]
public async Task WarnExpire() public async partial Task WarnExpire()
{ {
var expireDays = await _service.GetWarnExpire(ctx.Guild.Id); var expireDays = await _service.GetWarnExpire(ctx.Guild.Id);
@@ -125,13 +122,12 @@ public partial class Administration
await ReplyErrorLocalizedAsync(strs.warns_expire_in(expireDays)); await ReplyErrorLocalizedAsync(strs.warns_expire_in(expireDays));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[NadekoOptions(typeof(WarnExpireOptions))] [NadekoOptions(typeof(WarnExpireOptions))]
[Priority(2)] [Priority(2)]
public async Task WarnExpire(int days, params string[] args) public async partial Task WarnExpire(int days, params string[] args)
{ {
if (days is < 0 or > 366) if (days is < 0 or > 366)
return; return;
@@ -153,23 +149,21 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.warn_expire_set_clear(Format.Bold(days.ToString()))); await ReplyConfirmLocalizedAsync(strs.warn_expire_set_clear(Format.Bold(days.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
[Priority(2)] [Priority(2)]
public Task Warnlog(int page, [Leftover] IGuildUser user = null) public partial Task Warnlog(int page, [Leftover] IGuildUser user = null)
{ {
user ??= (IGuildUser)ctx.User; user ??= (IGuildUser)ctx.User;
return Warnlog(page, user.Id); return Warnlog(page, user.Id);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(3)] [Priority(3)]
public Task Warnlog(IGuildUser user = null) public partial Task Warnlog(IGuildUser user = null)
{ {
user ??= (IGuildUser)ctx.User; user ??= (IGuildUser)ctx.User;
@@ -178,20 +172,18 @@ public partial class Administration
: Task.CompletedTask; : Task.CompletedTask;
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
[Priority(0)] [Priority(0)]
public Task Warnlog(int page, ulong userId) public partial Task Warnlog(int page, ulong userId)
=> InternalWarnlog(userId, page - 1); => InternalWarnlog(userId, page - 1);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
[Priority(1)] [Priority(1)]
public Task Warnlog(ulong userId) public partial Task Warnlog(ulong userId)
=> InternalWarnlog(userId, 0); => InternalWarnlog(userId, 0);
private async Task InternalWarnlog(ulong userId, int inputPage) private async Task InternalWarnlog(ulong userId, int inputPage)
@@ -244,11 +236,10 @@ public partial class Administration
9); 9);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
public async Task WarnlogAll(int page = 1) public async partial Task WarnlogAll(int page = 1)
{ {
if (--page < 0) if (--page < 0)
return; return;
@@ -279,18 +270,16 @@ public partial class Administration
15); 15);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
public Task Warnclear(IGuildUser user, int index = 0) public partial Task Warnclear(IGuildUser user, int index = 0)
=> Warnclear(user.Id, index); => Warnclear(user.Id, index);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
public async Task Warnclear(ulong userId, int index = 0) public async partial Task Warnclear(ulong userId, int index = 0)
{ {
if (index < 0) if (index < 0)
return; return;
@@ -309,12 +298,11 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
[Priority(1)] [Priority(1)]
public async Task WarnPunish( public async partial Task WarnPunish(
int number, int number,
AddRole _, AddRole _,
IRole role, IRole role,
@@ -343,11 +331,10 @@ public partial class Administration
Format.Bold(time.Input))); Format.Bold(time.Input)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
public async Task WarnPunish(int number, PunishmentAction punish, StoopidTime time = null) public async partial Task WarnPunish(int number, PunishmentAction punish, StoopidTime time = null)
{ {
// this should never happen. Addrole has its own method with higher priority // this should never happen. Addrole has its own method with higher priority
if (punish == PunishmentAction.AddRole) if (punish == PunishmentAction.AddRole)
@@ -367,21 +354,19 @@ public partial class Administration
Format.Bold(time.Input))); Format.Bold(time.Input)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
public async Task WarnPunish(int number) public async partial Task WarnPunish(int number)
{ {
if (!_service.WarnPunishRemove(ctx.Guild.Id, number)) return; if (!_service.WarnPunishRemove(ctx.Guild.Id, number)) return;
await ReplyConfirmLocalizedAsync(strs.warn_punish_rem(Format.Bold(number.ToString()))); await ReplyConfirmLocalizedAsync(strs.warn_punish_rem(Format.Bold(number.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task WarnPunishList() public async partial Task WarnPunishList()
{ {
var ps = _service.WarnPunishList(ctx.Guild.Id); var ps = _service.WarnPunishList(ctx.Guild.Id);
@@ -395,13 +380,12 @@ public partial class Administration
await SendConfirmAsync(GetText(strs.warn_punish_list), list); await SendConfirmAsync(GetText(strs.warn_punish_list), list);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
[BotPerm(GuildPerm.BanMembers)] [BotPerm(GuildPerm.BanMembers)]
[Priority(1)] [Priority(1)]
public async Task Ban(StoopidTime time, IUser user, [Leftover] string msg = null) public async partial Task Ban(StoopidTime time, IUser user, [Leftover] string msg = null)
{ {
if (time.Time > TimeSpan.FromDays(49)) if (time.Time > TimeSpan.FromDays(49))
return; return;
@@ -440,13 +424,12 @@ public partial class Administration
await ctx.Channel.EmbedAsync(toSend); await ctx.Channel.EmbedAsync(toSend);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
[BotPerm(GuildPerm.BanMembers)] [BotPerm(GuildPerm.BanMembers)]
[Priority(0)] [Priority(0)]
public async Task Ban(ulong userId, [Leftover] string msg = null) public async partial Task Ban(ulong userId, [Leftover] string msg = null)
{ {
var user = await ((DiscordSocketClient)Context.Client).Rest.GetGuildUserAsync(ctx.Guild.Id, userId); var user = await ((DiscordSocketClient)Context.Client).Rest.GetGuildUserAsync(ctx.Guild.Id, userId);
if (user is null) if (user is null)
@@ -464,13 +447,12 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
[BotPerm(GuildPerm.BanMembers)] [BotPerm(GuildPerm.BanMembers)]
[Priority(2)] [Priority(2)]
public async Task Ban(IGuildUser user, [Leftover] string msg = null) public async partial Task Ban(IGuildUser user, [Leftover] string msg = null)
{ {
if (!await CheckRoleHierarchy(user)) if (!await CheckRoleHierarchy(user))
return; return;
@@ -501,12 +483,11 @@ public partial class Administration
await ctx.Channel.EmbedAsync(toSend); await ctx.Channel.EmbedAsync(toSend);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
[BotPerm(GuildPerm.BanMembers)] [BotPerm(GuildPerm.BanMembers)]
public async Task BanMessage([Leftover] string message = null) public async partial Task BanMessage([Leftover] string message = null)
{ {
if (message is null) if (message is null)
{ {
@@ -525,33 +506,30 @@ public partial class Administration
await ctx.OkAsync(); await ctx.OkAsync();
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
[BotPerm(GuildPerm.BanMembers)] [BotPerm(GuildPerm.BanMembers)]
public async Task BanMsgReset() public async partial Task BanMsgReset()
{ {
_service.SetBanTemplate(ctx.Guild.Id, null); _service.SetBanTemplate(ctx.Guild.Id, null);
await ctx.OkAsync(); await ctx.OkAsync();
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
[BotPerm(GuildPerm.BanMembers)] [BotPerm(GuildPerm.BanMembers)]
[Priority(0)] [Priority(0)]
public Task BanMessageTest([Leftover] string reason = null) public partial Task BanMessageTest([Leftover] string reason = null)
=> InternalBanMessageTest(reason, null); => InternalBanMessageTest(reason, null);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
[BotPerm(GuildPerm.BanMembers)] [BotPerm(GuildPerm.BanMembers)]
[Priority(1)] [Priority(1)]
public Task BanMessageTest(StoopidTime duration, [Leftover] string reason = null) public partial Task BanMessageTest(StoopidTime duration, [Leftover] string reason = null)
=> InternalBanMessageTest(reason, duration.Time); => InternalBanMessageTest(reason, duration.Time);
private async Task InternalBanMessageTest(string reason, TimeSpan? duration) private async Task InternalBanMessageTest(string reason, TimeSpan? duration)
@@ -579,12 +557,11 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
[BotPerm(GuildPerm.BanMembers)] [BotPerm(GuildPerm.BanMembers)]
public async Task Unban([Leftover] string user) public async partial Task Unban([Leftover] string user)
{ {
var bans = await ctx.Guild.GetBansAsync(); var bans = await ctx.Guild.GetBansAsync();
@@ -599,12 +576,11 @@ public partial class Administration
await UnbanInternal(bun.User); await UnbanInternal(bun.User);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
[BotPerm(GuildPerm.BanMembers)] [BotPerm(GuildPerm.BanMembers)]
public async Task Unban(ulong userId) public async partial Task Unban(ulong userId)
{ {
var bans = await ctx.Guild.GetBansAsync(); var bans = await ctx.Guild.GetBansAsync();
@@ -626,20 +602,18 @@ public partial class Administration
await ReplyConfirmLocalizedAsync(strs.unbanned_user(Format.Bold(user.ToString()))); await ReplyConfirmLocalizedAsync(strs.unbanned_user(Format.Bold(user.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.KickMembers | GuildPerm.ManageMessages)] [UserPerm(GuildPerm.KickMembers | GuildPerm.ManageMessages)]
[BotPerm(GuildPerm.BanMembers)] [BotPerm(GuildPerm.BanMembers)]
public Task Softban(IGuildUser user, [Leftover] string msg = null) public partial Task Softban(IGuildUser user, [Leftover] string msg = null)
=> SoftbanInternal(user, msg); => SoftbanInternal(user, msg);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.KickMembers | GuildPerm.ManageMessages)] [UserPerm(GuildPerm.KickMembers | GuildPerm.ManageMessages)]
[BotPerm(GuildPerm.BanMembers)] [BotPerm(GuildPerm.BanMembers)]
public async Task Softban(ulong userId, [Leftover] string msg = null) public async partial Task Softban(ulong userId, [Leftover] string msg = null)
{ {
var user = await ((DiscordSocketClient)Context.Client).Rest.GetGuildUserAsync(ctx.Guild.Id, userId); var user = await ((DiscordSocketClient)Context.Client).Rest.GetGuildUserAsync(ctx.Guild.Id, userId);
if (user is null) if (user is null)
@@ -679,22 +653,20 @@ public partial class Administration
await ctx.Channel.EmbedAsync(toSend); await ctx.Channel.EmbedAsync(toSend);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.KickMembers)] [UserPerm(GuildPerm.KickMembers)]
[BotPerm(GuildPerm.KickMembers)] [BotPerm(GuildPerm.KickMembers)]
[Priority(1)] [Priority(1)]
public Task Kick(IGuildUser user, [Leftover] string msg = null) public partial Task Kick(IGuildUser user, [Leftover] string msg = null)
=> KickInternal(user, msg); => KickInternal(user, msg);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.KickMembers)] [UserPerm(GuildPerm.KickMembers)]
[BotPerm(GuildPerm.KickMembers)] [BotPerm(GuildPerm.KickMembers)]
[Priority(0)] [Priority(0)]
public async Task Kick(ulong userId, [Leftover] string msg = null) public async partial Task Kick(ulong userId, [Leftover] string msg = null)
{ {
var user = await ((DiscordSocketClient)Context.Client).Rest.GetGuildUserAsync(ctx.Guild.Id, userId); var user = await ((DiscordSocketClient)Context.Client).Rest.GetGuildUserAsync(ctx.Guild.Id, userId);
if (user is null) if (user is null)
@@ -703,7 +675,7 @@ public partial class Administration
await KickInternal(user, msg); await KickInternal(user, msg);
} }
public async Task KickInternal(IGuildUser user, string msg = null) private async Task KickInternal(IGuildUser user, string msg = null)
{ {
if (!await CheckRoleHierarchy(user)) if (!await CheckRoleHierarchy(user))
return; return;
@@ -732,13 +704,12 @@ public partial class Administration
await ctx.Channel.EmbedAsync(toSend); await ctx.Channel.EmbedAsync(toSend);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
[BotPerm(GuildPerm.BanMembers)] [BotPerm(GuildPerm.BanMembers)]
[Ratelimit(30)] [Ratelimit(30)]
public async Task MassBan(params string[] userStrings) public async partial Task MassBan(params string[] userStrings)
{ {
if (userStrings.Length == 0) if (userStrings.Length == 0)
return; return;
@@ -806,13 +777,12 @@ public partial class Administration
.Build()); .Build());
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)] [UserPerm(GuildPerm.BanMembers)]
[BotPerm(GuildPerm.BanMembers)] [BotPerm(GuildPerm.BanMembers)]
[OwnerOnly] [OwnerOnly]
public async Task MassKill([Leftover] string people) public async partial Task MassKill([Leftover] string people)
{ {
if (string.IsNullOrWhiteSpace(people)) if (string.IsNullOrWhiteSpace(people))
return; return;

View File

@@ -6,14 +6,13 @@ namespace NadekoBot.Modules.Administration;
public partial class Administration public partial class Administration
{ {
[Group] [Group]
public class VcRoleCommands : NadekoSubmodule<VcRoleService> public partial class VcRoleCommands : NadekoSubmodule<VcRoleService>
{ {
[NadekoCommand] [Cmd]
[Aliases]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task VcRoleRm(ulong vcId) public async partial Task VcRoleRm(ulong vcId)
{ {
if (_service.RemoveVcRole(ctx.Guild.Id, vcId)) if (_service.RemoveVcRole(ctx.Guild.Id, vcId))
await ReplyConfirmLocalizedAsync(strs.vcrole_removed(Format.Bold(vcId.ToString()))); await ReplyConfirmLocalizedAsync(strs.vcrole_removed(Format.Bold(vcId.ToString())));
@@ -21,12 +20,11 @@ public partial class Administration
await ReplyErrorLocalizedAsync(strs.vcrole_not_found); await ReplyErrorLocalizedAsync(strs.vcrole_not_found);
} }
[NadekoCommand] [Cmd]
[Aliases]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task VcRole([Leftover] IRole role = null) public async partial Task VcRole([Leftover] IRole role = null)
{ {
var user = (IGuildUser)ctx.User; var user = (IGuildUser)ctx.User;
@@ -50,10 +48,9 @@ public partial class Administration
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task VcRoleList() public async partial Task VcRoleList()
{ {
var guild = (SocketGuild)ctx.Guild; var guild = (SocketGuild)ctx.Guild;
string text; string text;

View File

@@ -3,7 +3,7 @@ using NadekoBot.Modules.CustomReactions.Services;
namespace NadekoBot.Modules.CustomReactions; namespace NadekoBot.Modules.CustomReactions;
public class CustomReactions : NadekoModule<CustomReactionsService> public partial class CustomReactions : NadekoModule<CustomReactionsService>
{ {
public enum All public enum All
{ {
@@ -23,9 +23,8 @@ public class CustomReactions : NadekoModule<CustomReactionsService>
=> (ctx.Guild is null && _creds.IsOwner(ctx.User)) => (ctx.Guild is null && _creds.IsOwner(ctx.User))
|| (ctx.Guild != null && ((IGuildUser)ctx.User).GuildPermissions.Administrator); || (ctx.Guild != null && ((IGuildUser)ctx.User).GuildPermissions.Administrator);
[NadekoCommand] [Cmd]
[Aliases] public async partial Task AddCustReact(string key, [Leftover] string message)
public async Task AddCustReact(string key, [Leftover] string message)
{ {
var channel = ctx.Channel as ITextChannel; var channel = ctx.Channel as ITextChannel;
if (string.IsNullOrWhiteSpace(message) || string.IsNullOrWhiteSpace(key)) if (string.IsNullOrWhiteSpace(message) || string.IsNullOrWhiteSpace(key))
@@ -48,9 +47,8 @@ public class CustomReactions : NadekoModule<CustomReactionsService>
message.Length > 1024 ? GetText(strs.redacted_too_long) : message)); message.Length > 1024 ? GetText(strs.redacted_too_long) : message));
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task EditCustReact(kwum id, [Leftover] string message)
public async Task EditCustReact(kwum id, [Leftover] string message)
{ {
var channel = ctx.Channel as ITextChannel; var channel = ctx.Channel as ITextChannel;
if (string.IsNullOrWhiteSpace(message) || id < 0) if (string.IsNullOrWhiteSpace(message) || id < 0)
@@ -76,10 +74,9 @@ public class CustomReactions : NadekoModule<CustomReactionsService>
await ReplyErrorLocalizedAsync(strs.edit_fail); await ReplyErrorLocalizedAsync(strs.edit_fail);
} }
[NadekoCommand] [Cmd]
[Aliases]
[Priority(1)] [Priority(1)]
public async Task ListCustReact(int page = 1) public async partial Task ListCustReact(int page = 1)
{ {
if (--page < 0 || page > 999) if (--page < 0 || page > 999)
return; return;
@@ -113,9 +110,8 @@ public class CustomReactions : NadekoModule<CustomReactionsService>
20); 20);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task ShowCustReact(kwum id)
public async Task ShowCustReact(kwum id)
{ {
var found = _service.GetCustomReaction(ctx.Guild?.Id, id); var found = _service.GetCustomReaction(ctx.Guild?.Id, id);
@@ -133,9 +129,8 @@ public class CustomReactions : NadekoModule<CustomReactionsService>
found.Response.TrimTo(1000).Replace("](", "]\\("))); found.Response.TrimTo(1000).Replace("](", "]\\(")));
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task DelCustReact(kwum id)
public async Task DelCustReact(kwum id)
{ {
if (!AdminInGuildOrOwnerInDm()) if (!AdminInGuildOrOwnerInDm())
{ {
@@ -156,9 +151,8 @@ public class CustomReactions : NadekoModule<CustomReactionsService>
await ReplyErrorLocalizedAsync(strs.no_found_id); await ReplyErrorLocalizedAsync(strs.no_found_id);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task CrReact(kwum id, params string[] emojiStrs)
public async Task CrReact(kwum id, params string[] emojiStrs)
{ {
if (!AdminInGuildOrOwnerInDm()) if (!AdminInGuildOrOwnerInDm())
{ {
@@ -211,30 +205,25 @@ public class CustomReactions : NadekoModule<CustomReactionsService>
string.Join(", ", succ.Select(x => x.ToString())))); string.Join(", ", succ.Select(x => x.ToString()))));
} }
[NadekoCommand] [Cmd]
[Aliases] public partial Task CrCa(kwum id)
public Task CrCa(kwum id)
=> InternalCrEdit(id, CustomReactionsService.CrField.ContainsAnywhere); => InternalCrEdit(id, CustomReactionsService.CrField.ContainsAnywhere);
[NadekoCommand] [Cmd]
[Aliases] public partial Task CrDm(kwum id)
public Task CrDm(kwum id)
=> InternalCrEdit(id, CustomReactionsService.CrField.DmResponse); => InternalCrEdit(id, CustomReactionsService.CrField.DmResponse);
[NadekoCommand] [Cmd]
[Aliases] public partial Task CrAd(kwum id)
public Task CrAd(kwum id)
=> InternalCrEdit(id, CustomReactionsService.CrField.AutoDelete); => InternalCrEdit(id, CustomReactionsService.CrField.AutoDelete);
[NadekoCommand] [Cmd]
[Aliases] public partial Task CrAt(kwum id)
public Task CrAt(kwum id)
=> InternalCrEdit(id, CustomReactionsService.CrField.AllowTarget); => InternalCrEdit(id, CustomReactionsService.CrField.AllowTarget);
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task CrsReload() public async partial Task CrsReload()
{ {
await _service.TriggerReloadCustomReactions(); await _service.TriggerReloadCustomReactions();
@@ -265,11 +254,10 @@ public class CustomReactions : NadekoModule<CustomReactionsService>
Format.Code(id.ToString()))); Format.Code(id.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task CrClear() public async partial Task CrClear()
{ {
if (await PromptUserConfirmAsync(_eb.Create() if (await PromptUserConfirmAsync(_eb.Create()
.WithTitle("Custom reaction clear") .WithTitle("Custom reaction clear")
@@ -280,9 +268,8 @@ public class CustomReactions : NadekoModule<CustomReactionsService>
} }
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task CrsExport()
public async Task CrsExport()
{ {
if (!AdminInGuildOrOwnerInDm()) if (!AdminInGuildOrOwnerInDm())
{ {
@@ -297,12 +284,11 @@ public class CustomReactions : NadekoModule<CustomReactionsService>
await ctx.Channel.SendFileAsync(stream, "crs-export.yml"); await ctx.Channel.SendFileAsync(stream, "crs-export.yml");
} }
[NadekoCommand] [Cmd]
[Aliases]
#if GLOBAL_NADEKO #if GLOBAL_NADEKO
[OwnerOnly] [OwnerOnly]
#endif #endif
public async Task CrsImport([Leftover] string input = null) public async partial Task CrsImport([Leftover] string input = null)
{ {
if (!AdminInGuildOrOwnerInDm()) if (!AdminInGuildOrOwnerInDm())
{ {

View File

@@ -11,7 +11,7 @@ namespace NadekoBot.Modules.Gambling;
public partial class Gambling public partial class Gambling
{ {
[Group] [Group]
public class AnimalRacingCommands : GamblingSubmodule<AnimalRaceService> public partial class AnimalRacingCommands : GamblingSubmodule<AnimalRaceService>
{ {
private readonly ICurrencyService _cs; private readonly ICurrencyService _cs;
private readonly DiscordSocketClient _client; private readonly DiscordSocketClient _client;
@@ -31,11 +31,10 @@ public partial class Gambling
_gamesConf = gamesConf; _gamesConf = gamesConf;
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[NadekoOptionsAttribute(typeof(RaceOptions))] [NadekoOptionsAttribute(typeof(RaceOptions))]
public Task Race(params string[] args) public partial Task Race(params string[] args)
{ {
var (options, success) = OptionsParser.ParseFrom(new RaceOptions(), args); var (options, success) = OptionsParser.ParseFrom(new RaceOptions(), args);
@@ -124,10 +123,9 @@ public partial class Gambling
return ReplyErrorLocalizedAsync(strs.animal_race_failed); return ReplyErrorLocalizedAsync(strs.animal_race_failed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task JoinRace(ShmartNumber amount = default) public async partial Task JoinRace(ShmartNumber amount = default)
{ {
if (!await CheckBetOptional(amount)) if (!await CheckBetOptional(amount))
return; return;

View File

@@ -7,7 +7,7 @@ namespace NadekoBot.Modules.Gambling;
public partial class Gambling public partial class Gambling
{ {
public class BlackJackCommands : GamblingSubmodule<BlackJackService> public partial class BlackJackCommands : GamblingSubmodule<BlackJackService>
{ {
public enum BjAction public enum BjAction
{ {
@@ -27,10 +27,9 @@ public partial class Gambling
_db = db; _db = db;
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task BlackJack(ShmartNumber amount) public async partial Task BlackJack(ShmartNumber amount)
{ {
if (!await CheckBetMandatory(amount)) if (!await CheckBetMandatory(amount))
return; return;
@@ -152,25 +151,22 @@ public partial class Gambling
return $"{playerName} | Bet: {x.Bet}\n"; return $"{playerName} | Bet: {x.Bet}\n";
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public Task Hit() public partial Task Hit()
=> InternalBlackJack(BjAction.Hit); => InternalBlackJack(BjAction.Hit);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public Task Stand() public partial Task Stand()
=> InternalBlackJack(BjAction.Stand); => InternalBlackJack(BjAction.Stand);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public Task Double() public partial Task Double()
=> InternalBlackJack(BjAction.Double); => InternalBlackJack(BjAction.Double);
public async Task InternalBlackJack(BjAction a) private async Task InternalBlackJack(BjAction a)
{ {
if (!_service.Games.TryGetValue(ctx.Channel.Id, out var bj)) if (!_service.Games.TryGetValue(ctx.Channel.Id, out var bj))
return; return;

View File

@@ -9,7 +9,7 @@ namespace NadekoBot.Modules.Gambling;
public partial class Gambling public partial class Gambling
{ {
[Group] [Group]
public class Connect4Commands : GamblingSubmodule<GamblingService> public partial class Connect4Commands : GamblingSubmodule<GamblingService>
{ {
private static readonly string[] numbers = private static readonly string[] numbers =
{ {
@@ -41,11 +41,10 @@ public partial class Gambling
_cs = cs; _cs = cs;
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[NadekoOptionsAttribute(typeof(Connect4Game.Options))] [NadekoOptionsAttribute(typeof(Connect4Game.Options))]
public async Task Connect4(params string[] args) public async partial Task Connect4(params string[] args)
{ {
var (options, _) = OptionsParser.ParseFrom(new Connect4Game.Options(), args); var (options, _) = OptionsParser.ParseFrom(new Connect4Game.Options(), args);
if (!await CheckBetOptional(options.Bet)) if (!await CheckBetOptional(options.Bet))

View File

@@ -9,19 +9,18 @@ namespace NadekoBot.Modules.Gambling;
public partial class Gambling public partial class Gambling
{ {
[Group] [Group]
public class CurrencyEventsCommands : GamblingSubmodule<CurrencyEventsService> public partial class CurrencyEventsCommands : GamblingSubmodule<CurrencyEventsService>
{ {
public CurrencyEventsCommands(GamblingConfigService gamblingConf) public CurrencyEventsCommands(GamblingConfigService gamblingConf)
: base(gamblingConf) : base(gamblingConf)
{ {
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[NadekoOptionsAttribute(typeof(EventOptions))] [NadekoOptionsAttribute(typeof(EventOptions))]
[OwnerOnly] [OwnerOnly]
public async Task EventStart(CurrencyEvent.Type ev, params string[] options) public async partial Task EventStart(CurrencyEvent.Type ev, params string[] options)
{ {
var (opts, _) = OptionsParser.ParseFrom(new EventOptions(), options); var (opts, _) = OptionsParser.ParseFrom(new EventOptions(), options);
if (!await _service.TryCreateEventAsync(ctx.Guild.Id, ctx.Channel.Id, ev, opts, GetEmbed)) if (!await _service.TryCreateEventAsync(ctx.Guild.Id, ctx.Channel.Id, ev, opts, GetEmbed))

View File

@@ -6,7 +6,7 @@ namespace NadekoBot.Modules.Gambling;
public partial class Gambling public partial class Gambling
{ {
public class CurrencyRaffleCommands : GamblingSubmodule<CurrencyRaffleService> public partial class CurrencyRaffleCommands : GamblingSubmodule<CurrencyRaffleService>
{ {
public enum Mixed { Mixed } public enum Mixed { Mixed }
@@ -15,18 +15,16 @@ public partial class Gambling
{ {
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(0)] [Priority(0)]
public Task RaffleCur(Mixed _, ShmartNumber amount) public partial Task RaffleCur(Mixed _, ShmartNumber amount)
=> RaffleCur(amount, true); => RaffleCur(amount, true);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(1)] [Priority(1)]
public async Task RaffleCur(ShmartNumber amount, bool mixed = false) public async partial Task RaffleCur(ShmartNumber amount, bool mixed = false)
{ {
if (!await CheckBetMandatory(amount)) if (!await CheckBetMandatory(amount))
return; return;

View File

@@ -9,7 +9,7 @@ namespace NadekoBot.Modules.Gambling;
public partial class Gambling public partial class Gambling
{ {
[Group] [Group]
public class DiceRollCommands : NadekoSubmodule public partial class DiceRollCommands : NadekoSubmodule
{ {
private static readonly Regex dndRegex = new(@"^(?<n1>\d+)d(?<n2>\d+)(?:\+(?<add>\d+))?(?:\-(?<sub>\d+))?$", private static readonly Regex dndRegex = new(@"^(?<n1>\d+)d(?<n2>\d+)(?:\+(?<add>\d+))?(?:\-(?<sub>\d+))?$",
RegexOptions.Compiled); RegexOptions.Compiled);
@@ -22,9 +22,8 @@ public partial class Gambling
public DiceRollCommands(IDataCache data) public DiceRollCommands(IDataCache data)
=> _images = data.LocalImages; => _images = data.LocalImages;
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Roll()
public async Task Roll()
{ {
var rng = new NadekoRandom(); var rng = new NadekoRandom();
var gen = rng.Next(1, 101); var gen = rng.Next(1, 101);
@@ -41,29 +40,25 @@ public partial class Gambling
Format.Bold(ctx.User.ToString()) + " " + GetText(strs.dice_rolled(Format.Code(gen.ToString())))); Format.Bold(ctx.User.ToString()) + " " + GetText(strs.dice_rolled(Format.Code(gen.ToString()))));
} }
[NadekoCommand] [Cmd]
[Aliases]
[Priority(1)] [Priority(1)]
public async Task Roll(int num) public async partial Task Roll(int num)
=> await InternalRoll(num, true); => await InternalRoll(num, true);
[NadekoCommand] [Cmd]
[Aliases]
[Priority(1)] [Priority(1)]
public async Task Rolluo(int num = 1) public async partial Task Rolluo(int num = 1)
=> await InternalRoll(num, false); => await InternalRoll(num, false);
[NadekoCommand] [Cmd]
[Aliases]
[Priority(0)] [Priority(0)]
public async Task Roll(string arg) public async partial Task Roll(string arg)
=> await InternallDndRoll(arg, true); => await InternallDndRoll(arg, true);
[NadekoCommand] [Cmd]
[Aliases]
[Priority(0)] [Priority(0)]
public async Task Rolluo(string arg) public async partial Task Rolluo(string arg)
=> await InternallDndRoll(arg, false); => await InternallDndRoll(arg, false);
private async Task InternalRoll(int num, bool ordered) private async Task InternalRoll(int num, bool ordered)
@@ -174,9 +169,8 @@ public partial class Gambling
} }
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task NRoll([Leftover] string range)
public async Task NRoll([Leftover] string range)
{ {
int rolled; int rolled;
if (range.Contains("-")) if (range.Contains("-"))

View File

@@ -9,7 +9,7 @@ namespace NadekoBot.Modules.Gambling;
public partial class Gambling public partial class Gambling
{ {
[Group] [Group]
public class DrawCommands : NadekoSubmodule public partial class DrawCommands : NadekoSubmodule
{ {
private static readonly ConcurrentDictionary<IGuild, Deck> _allDecks = new(); private static readonly ConcurrentDictionary<IGuild, Deck> _allDecks = new();
private readonly IImageCache _images; private readonly IImageCache _images;
@@ -59,10 +59,9 @@ public partial class Gambling
return (img.ToStream(), toSend); return (img.ToStream(), toSend);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Draw(int num = 1) public async partial Task Draw(int num = 1)
{ {
if (num < 1) if (num < 1)
num = 1; num = 1;
@@ -76,9 +75,8 @@ public partial class Gambling
} }
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task DrawNew(int num = 1)
public async Task DrawNew(int num = 1)
{ {
if (num < 1) if (num < 1)
num = 1; num = 1;
@@ -92,10 +90,9 @@ public partial class Gambling
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task DeckShuffle() public async partial Task DeckShuffle()
{ {
//var channel = (ITextChannel)ctx.Channel; //var channel = (ITextChannel)ctx.Channel;

View File

@@ -10,7 +10,7 @@ namespace NadekoBot.Modules.Gambling;
public partial class Gambling public partial class Gambling
{ {
[Group] [Group]
public class FlipCoinCommands : GamblingSubmodule<GamblingService> public partial class FlipCoinCommands : GamblingSubmodule<GamblingService>
{ {
public enum BetFlipGuess public enum BetFlipGuess
{ {
@@ -33,9 +33,8 @@ public partial class Gambling
_cs = cs; _cs = cs;
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Flip(int count = 1)
public async Task Flip(int count = 1)
{ {
if (count is > 10 or < 1) if (count is > 10 or < 1)
{ {
@@ -75,9 +74,8 @@ public partial class Gambling
await ctx.Channel.SendFileAsync(stream, $"{count} coins.{format.FileExtensions.First()}", msg); await ctx.Channel.SendFileAsync(stream, $"{count} coins.{format.FileExtensions.First()}", msg);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Betflip(ShmartNumber amount, BetFlipGuess guess)
public async Task Betflip(ShmartNumber amount, BetFlipGuess guess)
{ {
if (!await CheckBetMandatory(amount) || amount == 1) if (!await CheckBetMandatory(amount) || amount == 1)
return; return;

View File

@@ -74,9 +74,8 @@ public partial class Gambling : GamblingModule<GamblingService>
return n(uow.DiscordUser.GetUserCurrency(id)); return n(uow.DiscordUser.GetUserCurrency(id));
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Economy()
public async Task Economy()
{ {
var ec = _service.GetEconomy(); var ec = _service.GetEconomy();
decimal onePercent = 0; decimal onePercent = 0;
@@ -99,9 +98,8 @@ public partial class Gambling : GamblingModule<GamblingService>
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Timely()
public async Task Timely()
{ {
var val = _config.Timely.Amount; var val = _config.Timely.Amount;
var period = _config.Timely.Cooldown; var period = _config.Timely.Cooldown;
@@ -123,19 +121,17 @@ public partial class Gambling : GamblingModule<GamblingService>
await ReplyConfirmLocalizedAsync(strs.timely(n(val), period)); await ReplyConfirmLocalizedAsync(strs.timely(n(val), period));
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task TimelyReset() public async partial Task TimelyReset()
{ {
_cache.RemoveAllTimelyClaims(); _cache.RemoveAllTimelyClaims();
await ReplyConfirmLocalizedAsync(strs.timely_reset); await ReplyConfirmLocalizedAsync(strs.timely_reset);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task TimelySet(int amount, int period = 24) public async partial Task TimelySet(int amount, int period = 24)
{ {
if (amount < 0 || period < 0) if (amount < 0 || period < 0)
return; return;
@@ -152,10 +148,9 @@ public partial class Gambling : GamblingModule<GamblingService>
await ReplyConfirmLocalizedAsync(strs.timely_set(Format.Bold(n(amount)), Format.Bold(period.ToString()))); await ReplyConfirmLocalizedAsync(strs.timely_set(Format.Bold(n(amount)), Format.Bold(period.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Raffle([Leftover] IRole role = null) public async partial Task Raffle([Leftover] IRole role = null)
{ {
role ??= ctx.Guild.EveryoneRole; role ??= ctx.Guild.EveryoneRole;
@@ -168,10 +163,9 @@ public partial class Gambling : GamblingModule<GamblingService>
footer: $"ID: {usr.Id}"); footer: $"ID: {usr.Id}");
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task RaffleAny([Leftover] IRole role = null) public async partial Task RaffleAny([Leftover] IRole role = null)
{ {
role ??= ctx.Guild.EveryoneRole; role ??= ctx.Guild.EveryoneRole;
@@ -184,24 +178,21 @@ public partial class Gambling : GamblingModule<GamblingService>
footer: $"ID: {usr.Id}"); footer: $"ID: {usr.Id}");
} }
[NadekoCommand] [Cmd]
[Aliases]
[Priority(2)] [Priority(2)]
public Task CurrencyTransactions(int page = 1) public partial Task CurrencyTransactions(int page = 1)
=> InternalCurrencyTransactions(ctx.User.Id, page); => InternalCurrencyTransactions(ctx.User.Id, page);
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
[Priority(0)] [Priority(0)]
public Task CurrencyTransactions([Leftover] IUser usr) public partial Task CurrencyTransactions([Leftover] IUser usr)
=> InternalCurrencyTransactions(usr.Id, 1); => InternalCurrencyTransactions(usr.Id, 1);
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
[Priority(1)] [Priority(1)]
public Task CurrencyTransactions(IUser usr, int page) public partial Task CurrencyTransactions(IUser usr, int page)
=> InternalCurrencyTransactions(usr.Id, page); => InternalCurrencyTransactions(usr.Id, page);
private async Task InternalCurrencyTransactions(ulong userId, int page) private async Task InternalCurrencyTransactions(ulong userId, int page)
@@ -233,26 +224,23 @@ public partial class Gambling : GamblingModule<GamblingService>
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[Priority(0)] [Priority(0)]
public async Task Cash(ulong userId) public async partial Task Cash(ulong userId)
=> await ReplyConfirmLocalizedAsync(strs.has(Format.Code(userId.ToString()), $"{GetCurrency(userId)}")); => await ReplyConfirmLocalizedAsync(strs.has(Format.Code(userId.ToString()), $"{GetCurrency(userId)}"));
[NadekoCommand] [Cmd]
[Aliases]
[Priority(1)] [Priority(1)]
public async Task Cash([Leftover] IUser user = null) public async partial Task Cash([Leftover] IUser user = null)
{ {
user ??= ctx.User; user ??= ctx.User;
await ConfirmLocalizedAsync(strs.has(Format.Bold(user.ToString()), $"{GetCurrency(user.Id)}")); await ConfirmLocalizedAsync(strs.has(Format.Bold(user.ToString()), $"{GetCurrency(user.Id)}"));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(0)] [Priority(0)]
public async Task Give(ShmartNumber amount, IGuildUser receiver, [Leftover] string msg = null) public async partial Task Give(ShmartNumber amount, IGuildUser receiver, [Leftover] string msg = null)
{ {
if (amount <= 0 || ctx.User.Id == receiver.Id || receiver.IsBot) if (amount <= 0 || ctx.User.Id == receiver.Id || receiver.IsBot)
return; return;
@@ -268,34 +256,30 @@ public partial class Gambling : GamblingModule<GamblingService>
await ReplyConfirmLocalizedAsync(strs.gifted(n(amount), Format.Bold(receiver.ToString()))); await ReplyConfirmLocalizedAsync(strs.gifted(n(amount), Format.Bold(receiver.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(1)] [Priority(1)]
public Task Give(ShmartNumber amount, [Leftover] IGuildUser receiver) public partial Task Give(ShmartNumber amount, [Leftover] IGuildUser receiver)
=> Give(amount, receiver, null); => Give(amount, receiver, null);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[OwnerOnly] [OwnerOnly]
[Priority(0)] [Priority(0)]
public Task Award(long amount, IGuildUser usr, [Leftover] string msg) public partial Task Award(long amount, IGuildUser usr, [Leftover] string msg)
=> Award(amount, usr.Id, msg); => Award(amount, usr.Id, msg);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[OwnerOnly] [OwnerOnly]
[Priority(1)] [Priority(1)]
public Task Award(long amount, [Leftover] IGuildUser usr) public partial Task Award(long amount, [Leftover] IGuildUser usr)
=> Award(amount, usr.Id); => Award(amount, usr.Id);
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
[Priority(2)] [Priority(2)]
public async Task Award(long amount, ulong usrId, [Leftover] string msg = null) public async partial Task Award(long amount, ulong usrId, [Leftover] string msg = null)
{ {
if (amount <= 0) if (amount <= 0)
return; return;
@@ -315,12 +299,11 @@ public partial class Gambling : GamblingModule<GamblingService>
await ReplyConfirmLocalizedAsync(strs.awarded(n(amount), $"<@{usrId}>")); await ReplyConfirmLocalizedAsync(strs.awarded(n(amount), $"<@{usrId}>"));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[OwnerOnly] [OwnerOnly]
[Priority(3)] [Priority(3)]
public async Task Award(long amount, [Leftover] IRole role) public async partial Task Award(long amount, [Leftover] IRole role)
{ {
var users = (await ctx.Guild.GetUsersAsync()).Where(u => u.GetRoles().Contains(role)).ToList(); var users = (await ctx.Guild.GetUsersAsync()).Where(u => u.GetRoles().Contains(role)).ToList();
@@ -334,12 +317,11 @@ public partial class Gambling : GamblingModule<GamblingService>
Format.Bold(role.Name))); Format.Bold(role.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[OwnerOnly] [OwnerOnly]
[Priority(0)] [Priority(0)]
public async Task Take(long amount, [Leftover] IRole role) public async partial Task Take(long amount, [Leftover] IRole role)
{ {
var users = (await role.GetMembersAsync()).ToList(); var users = (await role.GetMembersAsync()).ToList();
@@ -353,12 +335,11 @@ public partial class Gambling : GamblingModule<GamblingService>
Format.Bold(role.Name))); Format.Bold(role.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[OwnerOnly] [OwnerOnly]
[Priority(1)] [Priority(1)]
public async Task Take(long amount, [Leftover] IGuildUser user) public async partial Task Take(long amount, [Leftover] IGuildUser user)
{ {
if (amount <= 0) if (amount <= 0)
return; return;
@@ -373,10 +354,9 @@ public partial class Gambling : GamblingModule<GamblingService>
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task Take(long amount, [Leftover] ulong usrId) public async partial Task Take(long amount, [Leftover] ulong usrId)
{ {
if (amount <= 0) if (amount <= 0)
return; return;
@@ -390,10 +370,9 @@ public partial class Gambling : GamblingModule<GamblingService>
await ReplyErrorLocalizedAsync(strs.take_fail(n(amount), Format.Code(usrId.ToString()), CurrencySign)); await ReplyErrorLocalizedAsync(strs.take_fail(n(amount), Format.Code(usrId.ToString()), CurrencySign));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task RollDuel(IUser u) public async partial Task RollDuel(IUser u)
{ {
if (ctx.User.Id == u.Id) if (ctx.User.Id == u.Id)
return; return;
@@ -403,10 +382,9 @@ public partial class Gambling : GamblingModule<GamblingService>
if (_service.Duels.TryRemove((ctx.User.Id, u.Id), out var game)) await game.StartGame(); if (_service.Duels.TryRemove((ctx.User.Id, u.Id), out var game)) await game.StartGame();
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task RollDuel(ShmartNumber amount, IUser u) public async partial Task RollDuel(ShmartNumber amount, IUser u)
{ {
if (ctx.User.Id == u.Id) if (ctx.User.Id == u.Id)
return; return;
@@ -517,23 +495,20 @@ public partial class Gambling : GamblingModule<GamblingService>
await SendConfirmAsync(str); await SendConfirmAsync(str);
} }
[NadekoCommand] [Cmd]
[Aliases] public partial Task BetRoll(ShmartNumber amount)
public Task BetRoll(ShmartNumber amount)
=> InternallBetroll(amount); => InternallBetroll(amount);
[NadekoCommand] [Cmd]
[Aliases]
[NadekoOptions(typeof(LbOpts))] [NadekoOptions(typeof(LbOpts))]
[Priority(0)] [Priority(0)]
public Task Leaderboard(params string[] args) public partial Task Leaderboard(params string[] args)
=> Leaderboard(1, args); => Leaderboard(1, args);
[NadekoCommand] [Cmd]
[Aliases]
[NadekoOptions(typeof(LbOpts))] [NadekoOptions(typeof(LbOpts))]
[Priority(1)] [Priority(1)]
public async Task Leaderboard(int page = 1, params string[] args) public async partial Task Leaderboard(int page = 1, params string[] args)
{ {
if (--page < 0) if (--page < 0)
return; return;
@@ -603,9 +578,8 @@ public partial class Gambling : GamblingModule<GamblingService>
opts.Clean); opts.Clean);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Rps(RpsPick pick, ShmartNumber amount = default)
public async Task Rps(RpsPick pick, ShmartNumber amount = default)
{ {
long oldAmount = amount; long oldAmount = amount;
if (!await CheckBetOptional(amount) || amount == 1) if (!await CheckBetOptional(amount) || amount == 1)

View File

@@ -8,7 +8,7 @@ namespace NadekoBot.Modules.Gambling;
public partial class Gambling public partial class Gambling
{ {
[Group] [Group]
public class PlantPickCommands : GamblingSubmodule<PlantPickService> public partial class PlantPickCommands : GamblingSubmodule<PlantPickService>
{ {
private readonly ILogCommandService logService; private readonly ILogCommandService logService;
@@ -16,10 +16,9 @@ public partial class Gambling
: base(gss) : base(gss)
=> this.logService = logService; => this.logService = logService;
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Pick(string pass = null) public async partial Task Pick(string pass = null)
{ {
if (!string.IsNullOrWhiteSpace(pass) && !pass.IsAlphaNumeric()) return; if (!string.IsNullOrWhiteSpace(pass) && !pass.IsAlphaNumeric()) return;
@@ -40,10 +39,9 @@ public partial class Gambling
catch { } catch { }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Plant(ShmartNumber amount, string pass = null) public async partial Task Plant(ShmartNumber amount, string pass = null)
{ {
if (amount < 1) if (amount < 1)
return; return;
@@ -65,14 +63,13 @@ public partial class Gambling
if (!success) await ReplyErrorLocalizedAsync(strs.not_enough(CurrencySign)); if (!success) await ReplyErrorLocalizedAsync(strs.not_enough(CurrencySign));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
#if GLOBAL_NADEKO #if GLOBAL_NADEKO
[OwnerOnly] [OwnerOnly]
#endif #endif
public async Task GenCurrency() public async partial Task GenCurrency()
{ {
var enabled = _service.ToggleCurrencyGeneration(ctx.Guild.Id, ctx.Channel.Id); var enabled = _service.ToggleCurrencyGeneration(ctx.Guild.Id, ctx.Channel.Id);
if (enabled) if (enabled)
@@ -81,12 +78,11 @@ public partial class Gambling
await ReplyConfirmLocalizedAsync(strs.curgen_disabled); await ReplyConfirmLocalizedAsync(strs.curgen_disabled);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
[OwnerOnly] [OwnerOnly]
public Task GenCurList(int page = 1) public partial Task GenCurList(int page = 1)
{ {
if (--page < 0) if (--page < 0)
return Task.CompletedTask; return Task.CompletedTask;

View File

@@ -11,7 +11,7 @@ namespace NadekoBot.Modules.Gambling;
public partial class Gambling public partial class Gambling
{ {
[Group] [Group]
public class ShopCommands : GamblingSubmodule<IShopService> public partial class ShopCommands : GamblingSubmodule<IShopService>
{ {
public enum List public enum List
{ {
@@ -65,10 +65,9 @@ public partial class Gambling
9); 9);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public Task Shop(int page = 1) public partial Task Shop(int page = 1)
{ {
if (--page < 0) if (--page < 0)
return Task.CompletedTask; return Task.CompletedTask;
@@ -76,10 +75,9 @@ public partial class Gambling
return ShopInternalAsync(page); return ShopInternalAsync(page);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Buy(int index) public async partial Task Buy(int index)
{ {
index -= 1; index -= 1;
if (index < 0) if (index < 0)
@@ -204,12 +202,11 @@ public partial class Gambling
private static long GetProfitAmount(int price) private static long GetProfitAmount(int price)
=> (int)Math.Ceiling(0.90 * price); => (int)Math.Ceiling(0.90 * price);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
public async Task ShopAdd(Role _, int price, [Leftover] IRole role) public async partial Task ShopAdd(Role _, int price, [Leftover] IRole role)
{ {
if (price < 1) if (price < 1)
return; return;
@@ -236,11 +233,10 @@ public partial class Gambling
await ctx.Channel.EmbedAsync(EntryToEmbed(entry).WithTitle(GetText(strs.shop_item_add))); await ctx.Channel.EmbedAsync(EntryToEmbed(entry).WithTitle(GetText(strs.shop_item_add)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task ShopAdd(List _, int price, [Leftover] string name) public async partial Task ShopAdd(List _, int price, [Leftover] string name)
{ {
if (price < 1) if (price < 1)
return; return;
@@ -266,11 +262,10 @@ public partial class Gambling
await ctx.Channel.EmbedAsync(EntryToEmbed(entry).WithTitle(GetText(strs.shop_item_add))); await ctx.Channel.EmbedAsync(EntryToEmbed(entry).WithTitle(GetText(strs.shop_item_add)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task ShopListAdd(int index, [Leftover] string itemText) public async partial Task ShopListAdd(int index, [Leftover] string itemText)
{ {
index -= 1; index -= 1;
if (index < 0) if (index < 0)
@@ -301,11 +296,10 @@ public partial class Gambling
await ReplyConfirmLocalizedAsync(strs.shop_list_item_added); await ReplyConfirmLocalizedAsync(strs.shop_list_item_added);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task ShopRemove(int index) public async partial Task ShopRemove(int index)
{ {
index -= 1; index -= 1;
if (index < 0) if (index < 0)
@@ -332,11 +326,10 @@ public partial class Gambling
await ctx.Channel.EmbedAsync(EntryToEmbed(removed).WithTitle(GetText(strs.shop_item_rm))); await ctx.Channel.EmbedAsync(EntryToEmbed(removed).WithTitle(GetText(strs.shop_item_rm)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task ShopChangePrice(int index, int price) public async partial Task ShopChangePrice(int index, int price)
{ {
if (--index < 0 || price <= 0) if (--index < 0 || price <= 0)
return; return;
@@ -353,11 +346,10 @@ public partial class Gambling
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task ShopChangeName(int index, [Leftover] string newName) public async partial Task ShopChangeName(int index, [Leftover] string newName)
{ {
if (--index < 0 || string.IsNullOrWhiteSpace(newName)) if (--index < 0 || string.IsNullOrWhiteSpace(newName))
return; return;
@@ -374,11 +366,10 @@ public partial class Gambling
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task ShopSwap(int index1, int index2) public async partial Task ShopSwap(int index1, int index2)
{ {
if (--index1 < 0 || --index2 < 0 || index1 == index2) if (--index1 < 0 || --index2 < 0 || index1 == index2)
return; return;
@@ -395,11 +386,10 @@ public partial class Gambling
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task ShopMove(int fromIndex, int toIndex) public async partial Task ShopMove(int fromIndex, int toIndex)
{ {
if (--fromIndex < 0 || --toIndex < 0 || fromIndex == toIndex) if (--fromIndex < 0 || --toIndex < 0 || fromIndex == toIndex)
return; return;

View File

@@ -16,7 +16,7 @@ namespace NadekoBot.Modules.Gambling;
public partial class Gambling public partial class Gambling
{ {
[Group] [Group]
public class SlotCommands : GamblingSubmodule<GamblingService> public partial class SlotCommands : GamblingSubmodule<GamblingService>
{ {
private static long _totalBet; private static long _totalBet;
private static long _totalPaidOut; private static long _totalPaidOut;
@@ -46,10 +46,9 @@ public partial class Gambling
public Task Test() public Task Test()
=> Task.CompletedTask; => Task.CompletedTask;
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task SlotStats() public async partial Task SlotStats()
{ {
//i remembered to not be a moron //i remembered to not be a moron
var paid = _totalPaidOut; var paid = _totalPaidOut;
@@ -68,10 +67,9 @@ public partial class Gambling
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task SlotTest(int tests = 1000) public async partial Task SlotTest(int tests = 1000)
{ {
if (tests <= 0) if (tests <= 0)
return; return;
@@ -99,9 +97,8 @@ public partial class Gambling
footer: $"Total Bet: {tests} | Payout: {payout} | {payout * 1.0f / tests * 100}%"); footer: $"Total Bet: {tests} | Payout: {payout} | {payout * 1.0f / tests * 100}%");
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Slot(ShmartNumber amount)
public async Task Slot(ShmartNumber amount)
{ {
if (!_runningUsers.Add(ctx.User.Id)) if (!_runningUsers.Add(ctx.User.Id))
return; return;

View File

@@ -8,16 +8,15 @@ namespace NadekoBot.Modules.Gambling;
public partial class Gambling public partial class Gambling
{ {
[Group] [Group]
public class WaifuClaimCommands : GamblingSubmodule<WaifuService> public partial class WaifuClaimCommands : GamblingSubmodule<WaifuService>
{ {
public WaifuClaimCommands(GamblingConfigService gamblingConfService) public WaifuClaimCommands(GamblingConfigService gamblingConfService)
: base(gamblingConfService) : base(gamblingConfService)
{ {
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task WaifuReset()
public async Task WaifuReset()
{ {
var price = _service.GetResetPrice(ctx.User); var price = _service.GetResetPrice(ctx.User);
var embed = _eb.Create() var embed = _eb.Create()
@@ -36,10 +35,9 @@ public partial class Gambling
await ReplyErrorLocalizedAsync(strs.waifu_reset_fail); await ReplyErrorLocalizedAsync(strs.waifu_reset_fail);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task WaifuClaim(int amount, [Leftover] IUser target) public async partial Task WaifuClaim(int amount, [Leftover] IUser target)
{ {
if (amount < _config.Waifu.MinPrice) if (amount < _config.Waifu.MinPrice)
{ {
@@ -76,11 +74,10 @@ public partial class Gambling
await SendConfirmAsync(ctx.User.Mention + msg); await SendConfirmAsync(ctx.User.Mention + msg);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(0)] [Priority(0)]
public async Task WaifuTransfer(ulong waifuId, IUser newOwner) public async partial Task WaifuTransfer(ulong waifuId, IUser newOwner)
{ {
if (!await _service.WaifuTransfer(ctx.User, waifuId, newOwner)) if (!await _service.WaifuTransfer(ctx.User, waifuId, newOwner))
{ {
@@ -93,11 +90,10 @@ public partial class Gambling
Format.Bold(newOwner.ToString()))); Format.Bold(newOwner.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(1)] [Priority(1)]
public async Task WaifuTransfer(IUser waifu, IUser newOwner) public async partial Task WaifuTransfer(IUser waifu, IUser newOwner)
{ {
if (!await _service.WaifuTransfer(ctx.User, waifu.Id, newOwner)) if (!await _service.WaifuTransfer(ctx.User, waifu.Id, newOwner))
{ {
@@ -110,11 +106,10 @@ public partial class Gambling
Format.Bold(newOwner.ToString()))); Format.Bold(newOwner.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(-1)] [Priority(-1)]
public Task Divorce([Leftover] string target) public partial Task Divorce([Leftover] string target)
{ {
var waifuUserId = _service.GetWaifuUserId(ctx.User.Id, target); var waifuUserId = _service.GetWaifuUserId(ctx.User.Id, target);
if (waifuUserId == default) return ReplyErrorLocalizedAsync(strs.waifu_not_yours); if (waifuUserId == default) return ReplyErrorLocalizedAsync(strs.waifu_not_yours);
@@ -122,18 +117,16 @@ public partial class Gambling
return Divorce(waifuUserId); return Divorce(waifuUserId);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(0)] [Priority(0)]
public Task Divorce([Leftover] IGuildUser target) public partial Task Divorce([Leftover] IGuildUser target)
=> Divorce(target.Id); => Divorce(target.Id);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(1)] [Priority(1)]
public async Task Divorce([Leftover] ulong targetId) public async partial Task Divorce([Leftover] ulong targetId)
{ {
if (targetId == ctx.User.Id) if (targetId == ctx.User.Id)
return; return;
@@ -153,10 +146,9 @@ public partial class Gambling
Format.Bold(remaining?.Minutes.ToString()))); Format.Bold(remaining?.Minutes.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Affinity([Leftover] IGuildUser u = null) public async partial Task Affinity([Leftover] IGuildUser u = null)
{ {
if (u?.Id == ctx.User.Id) if (u?.Id == ctx.User.Id)
{ {
@@ -185,10 +177,9 @@ public partial class Gambling
Format.Bold(u.ToString()))); Format.Bold(u.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task WaifuLb(int page = 1) public async partial Task WaifuLb(int page = 1)
{ {
page--; page--;
@@ -218,11 +209,10 @@ public partial class Gambling
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(1)] [Priority(1)]
public Task WaifuInfo([Leftover] IUser target = null) public partial Task WaifuInfo([Leftover] IUser target = null)
{ {
if (target is null) if (target is null)
target = ctx.User; target = ctx.User;
@@ -230,11 +220,10 @@ public partial class Gambling
return InternalWaifuInfo(target.Id, target.ToString()); return InternalWaifuInfo(target.Id, target.ToString());
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(0)] [Priority(0)]
public Task WaifuInfo(ulong targetId) public partial Task WaifuInfo(ulong targetId)
=> InternalWaifuInfo(targetId); => InternalWaifuInfo(targetId);
private Task InternalWaifuInfo(ulong targetId, string name = null) private Task InternalWaifuInfo(ulong targetId, string name = null)
@@ -284,11 +273,10 @@ public partial class Gambling
return ctx.Channel.EmbedAsync(embed); return ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(1)] [Priority(1)]
public async Task WaifuGift(int page = 1) public async partial Task WaifuGift(int page = 1)
{ {
if (--page < 0 || page > (_config.Waifu.Items.Count - 1) / 9) if (--page < 0 || page > (_config.Waifu.Items.Count - 1) / 9)
return; return;
@@ -315,11 +303,10 @@ public partial class Gambling
9); 9);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(0)] [Priority(0)]
public async Task WaifuGift(string itemName, [Leftover] IUser waifu) public async partial Task WaifuGift(string itemName, [Leftover] IUser waifu)
{ {
if (waifu.Id == ctx.User.Id) if (waifu.Id == ctx.User.Id)
return; return;

View File

@@ -8,7 +8,7 @@ namespace NadekoBot.Modules.Gambling;
public partial class Gambling public partial class Gambling
{ {
public class WheelOfFortuneCommands : GamblingSubmodule<GamblingService> public partial class WheelOfFortuneCommands : GamblingSubmodule<GamblingService>
{ {
private static readonly ImmutableArray<string> _emojis = private static readonly ImmutableArray<string> _emojis =
new[] { "⬆", "↖", "⬅", "↙", "⬇", "↘", "➡", "↗" }.ToImmutableArray(); new[] { "⬆", "↖", "⬅", "↙", "⬇", "↘", "➡", "↗" }.ToImmutableArray();
@@ -23,9 +23,8 @@ public partial class Gambling
_db = db; _db = db;
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task WheelOfFortune(ShmartNumber amount)
public async Task WheelOfFortune(ShmartNumber amount)
{ {
if (!await CheckBetMandatory(amount)) if (!await CheckBetMandatory(amount))
return; return;

View File

@@ -8,18 +8,17 @@ namespace NadekoBot.Modules.Games;
public partial class Games public partial class Games
{ {
[Group] [Group]
public class AcropobiaCommands : NadekoSubmodule<GamesService> public partial class AcropobiaCommands : NadekoSubmodule<GamesService>
{ {
private readonly DiscordSocketClient _client; private readonly DiscordSocketClient _client;
public AcropobiaCommands(DiscordSocketClient client) public AcropobiaCommands(DiscordSocketClient client)
=> _client = client; => _client = client;
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[NadekoOptions(typeof(AcrophobiaGame.Options))] [NadekoOptions(typeof(AcrophobiaGame.Options))]
public async Task Acrophobia(params string[] args) public async partial Task Acrophobia(params string[] args)
{ {
var (options, _) = OptionsParser.ParseFrom(new AcrophobiaGame.Options(), args); var (options, _) = OptionsParser.ParseFrom(new AcrophobiaGame.Options(), args);
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;

View File

@@ -7,7 +7,7 @@ namespace NadekoBot.Modules.Games;
public partial class Games public partial class Games
{ {
[Group] [Group]
public class ChatterBotCommands : NadekoSubmodule<ChatterBotService> public partial class ChatterBotCommands : NadekoSubmodule<ChatterBotService>
{ {
private readonly DbService _db; private readonly DbService _db;
@@ -15,11 +15,10 @@ public partial class Games
=> _db = db; => _db = db;
[NoPublicBot] [NoPublicBot]
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
public async Task Cleverbot() public async partial Task Cleverbot()
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;

View File

@@ -20,9 +20,8 @@ public partial class Games : NadekoModule<GamesService>
_httpFactory = factory; _httpFactory = factory;
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Choose([Leftover] string list = null)
public async Task Choose([Leftover] string list = null)
{ {
if (string.IsNullOrWhiteSpace(list)) if (string.IsNullOrWhiteSpace(list))
return; return;
@@ -33,9 +32,8 @@ public partial class Games : NadekoModule<GamesService>
await SendConfirmAsync("🤔", listArr[rng.Next(0, listArr.Length)]); await SendConfirmAsync("🤔", listArr[rng.Next(0, listArr.Length)]);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task EightBall([Leftover] string question = null)
public async Task EightBall([Leftover] string question = null)
{ {
if (string.IsNullOrWhiteSpace(question)) if (string.IsNullOrWhiteSpace(question))
return; return;
@@ -48,10 +46,9 @@ public partial class Games : NadekoModule<GamesService>
.AddField("🎱 " + GetText(strs._8ball), res)); .AddField("🎱 " + GetText(strs._8ball), res));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task RateGirl([Leftover] IGuildUser usr) public async partial Task RateGirl([Leftover] IGuildUser usr)
{ {
var gr = _service.GirlRatings.GetOrAdd(usr.Id, GetGirl); var gr = _service.GirlRatings.GetOrAdd(usr.Id, GetGirl);
var originalStream = await gr.Stream; var originalStream = await gr.Stream;
@@ -141,9 +138,8 @@ public partial class Games : NadekoModule<GamesService>
return new(_images, _httpFactory, crazy, hot, roll, advice); return new(_images, _httpFactory, crazy, hot, roll, advice);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Linux(string guhnoo, string loonix)
public async Task Linux(string guhnoo, string loonix)
=> await SendConfirmAsync( => await SendConfirmAsync(
$@"I'd just like to interject for moment. What you're refering to as {loonix}, is in fact, {guhnoo}/{loonix}, or as I've recently taken to calling it, {guhnoo} plus {loonix}. {loonix} is not an operating system unto itself, but rather another free component of a fully functioning {guhnoo} system made useful by the {guhnoo} corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX. $@"I'd just like to interject for moment. What you're refering to as {loonix}, is in fact, {guhnoo}/{loonix}, or as I've recently taken to calling it, {guhnoo} plus {loonix}. {loonix} is not an operating system unto itself, but rather another free component of a fully functioning {guhnoo} system made useful by the {guhnoo} corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX.

View File

@@ -5,12 +5,11 @@ namespace NadekoBot.Modules.Games;
public partial class Games public partial class Games
{ {
[Group] [Group]
public class HangmanCommands : NadekoSubmodule<IHangmanService> public partial class HangmanCommands : NadekoSubmodule<IHangmanService>
{ {
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Hangmanlist() public async partial Task Hangmanlist()
=> await SendConfirmAsync(GetText(strs.hangman_types(Prefix)), _service.GetHangmanTypes().Join('\n')); => await SendConfirmAsync(GetText(strs.hangman_types(Prefix)), _service.GetHangmanTypes().Join('\n'));
private static string Draw(HangmanGame.State state) private static string Draw(HangmanGame.State state)
@@ -44,10 +43,9 @@ public partial class Games
.WithFooter(state.missedLetters.Join(' ')); .WithFooter(state.missedLetters.Join(' '));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Hangman([Leftover] string? type = null) public async partial Task Hangman([Leftover] string? type = null)
{ {
if (!_service.StartHangman(ctx.Channel.Id, type, out var hangman)) if (!_service.StartHangman(ctx.Channel.Id, type, out var hangman))
{ {
@@ -60,10 +58,9 @@ public partial class Games
await ctx.Channel.EmbedAsync(eb); await ctx.Channel.EmbedAsync(eb);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task HangmanStop() public async partial Task HangmanStop()
{ {
if (await _service.StopHangman(ctx.Channel.Id)) await ReplyConfirmLocalizedAsync(strs.hangman_stopped); if (await _service.StopHangman(ctx.Channel.Id)) await ReplyConfirmLocalizedAsync(strs.hangman_stopped);
} }

View File

@@ -7,17 +7,16 @@ namespace NadekoBot.Modules.Games;
public partial class Games public partial class Games
{ {
[Group] [Group]
public class NunchiCommands : NadekoSubmodule<GamesService> public partial class NunchiCommands : NadekoSubmodule<GamesService>
{ {
private readonly DiscordSocketClient _client; private readonly DiscordSocketClient _client;
public NunchiCommands(DiscordSocketClient client) public NunchiCommands(DiscordSocketClient client)
=> _client = client; => _client = client;
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Nunchi() public async partial Task Nunchi()
{ {
var newNunchi = new NunchiGame(ctx.User.Id, ctx.User.ToString()); var newNunchi = new NunchiGame(ctx.User.Id, ctx.User.ToString());
NunchiGame nunchi; NunchiGame nunchi;

View File

@@ -8,18 +8,17 @@ namespace NadekoBot.Modules.Games;
public partial class Games public partial class Games
{ {
[Group] [Group]
public class PollCommands : NadekoSubmodule<PollService> public partial class PollCommands : NadekoSubmodule<PollService>
{ {
private readonly DiscordSocketClient _client; private readonly DiscordSocketClient _client;
public PollCommands(DiscordSocketClient client) public PollCommands(DiscordSocketClient client)
=> _client = client; => _client = client;
[NadekoCommand] [Cmd]
[Aliases]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Poll([Leftover] string arg) public async partial Task Poll([Leftover] string arg)
{ {
if (string.IsNullOrWhiteSpace(arg)) if (string.IsNullOrWhiteSpace(arg))
return; return;
@@ -44,11 +43,10 @@ public partial class Games
await ReplyErrorLocalizedAsync(strs.poll_already_running); await ReplyErrorLocalizedAsync(strs.poll_already_running);
} }
[NadekoCommand] [Cmd]
[Aliases]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task PollStats() public async partial Task PollStats()
{ {
if (!_service.ActivePolls.TryGetValue(ctx.Guild.Id, out var pr)) if (!_service.ActivePolls.TryGetValue(ctx.Guild.Id, out var pr))
return; return;
@@ -56,11 +54,10 @@ public partial class Games
await ctx.Channel.EmbedAsync(GetStats(pr.Poll, GetText(strs.current_poll_results))); await ctx.Channel.EmbedAsync(GetStats(pr.Poll, GetText(strs.current_poll_results)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Pollend() public async partial Task Pollend()
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;

View File

@@ -7,7 +7,7 @@ namespace NadekoBot.Modules.Games;
public partial class Games public partial class Games
{ {
[Group] [Group]
public class SpeedTypingCommands : NadekoSubmodule<GamesService> public partial class SpeedTypingCommands : NadekoSubmodule<GamesService>
{ {
private readonly GamesService _games; private readonly GamesService _games;
private readonly DiscordSocketClient _client; private readonly DiscordSocketClient _client;
@@ -18,11 +18,10 @@ public partial class Games
_client = client; _client = client;
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[NadekoOptionsAttribute(typeof(TypingGame.Options))] [NadekoOptionsAttribute(typeof(TypingGame.Options))]
public async Task TypeStart(params string[] args) public async partial Task TypeStart(params string[] args)
{ {
var (options, _) = OptionsParser.ParseFrom(new TypingGame.Options(), args); var (options, _) = OptionsParser.ParseFrom(new TypingGame.Options(), args);
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;
@@ -36,10 +35,9 @@ public partial class Games
await game.Start(); await game.Start();
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task TypeStop() public async partial Task TypeStop()
{ {
if (_service.RunningContests.TryRemove(ctx.Guild.Id, out var game)) if (_service.RunningContests.TryRemove(ctx.Guild.Id, out var game))
{ {
@@ -51,11 +49,10 @@ public partial class Games
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[OwnerOnly] [OwnerOnly]
public async Task Typeadd([Leftover] string text) public async partial Task Typeadd([Leftover] string text)
{ {
if (string.IsNullOrWhiteSpace(text)) if (string.IsNullOrWhiteSpace(text))
return; return;
@@ -65,10 +62,9 @@ public partial class Games
await SendConfirmAsync("Added new article for typing game."); await SendConfirmAsync("Added new article for typing game.");
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Typelist(int page = 1) public async partial Task Typelist(int page = 1)
{ {
if (page < 1) if (page < 1)
return; return;
@@ -86,11 +82,10 @@ public partial class Games
string.Join("\n", articles.Select(a => $"`#{++i}` - {a.Text.TrimTo(50)}"))); string.Join("\n", articles.Select(a => $"`#{++i}` - {a.Text.TrimTo(50)}")));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[OwnerOnly] [OwnerOnly]
public async Task Typedel(int index) public async partial Task Typedel(int index)
{ {
var removed = _service.RemoveTypingArticle(--index); var removed = _service.RemoveTypingArticle(--index);

View File

@@ -7,7 +7,7 @@ namespace NadekoBot.Modules.Games;
public partial class Games public partial class Games
{ {
[Group] [Group]
public class TicTacToeCommands : NadekoSubmodule<GamesService> public partial class TicTacToeCommands : NadekoSubmodule<GamesService>
{ {
private readonly SemaphoreSlim _sem = new(1, 1); private readonly SemaphoreSlim _sem = new(1, 1);
private readonly DiscordSocketClient _client; private readonly DiscordSocketClient _client;
@@ -15,11 +15,10 @@ public partial class Games
public TicTacToeCommands(DiscordSocketClient client) public TicTacToeCommands(DiscordSocketClient client)
=> _client = client; => _client = client;
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[NadekoOptions(typeof(TicTacToe.Options))] [NadekoOptions(typeof(TicTacToe.Options))]
public async Task TicTacToe(params string[] args) public async partial Task TicTacToe(params string[] args)
{ {
var (options, _) = OptionsParser.ParseFrom(new TicTacToe.Options(), args); var (options, _) = OptionsParser.ParseFrom(new TicTacToe.Options(), args);
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;

View File

@@ -7,7 +7,7 @@ namespace NadekoBot.Modules.Games;
public partial class Games public partial class Games
{ {
[Group] [Group]
public class TriviaCommands : NadekoSubmodule<GamesService> public partial class TriviaCommands : NadekoSubmodule<GamesService>
{ {
private readonly IDataCache _cache; private readonly IDataCache _cache;
private readonly ICurrencyService _cs; private readonly ICurrencyService _cs;
@@ -26,15 +26,14 @@ public partial class Games
_client = client; _client = client;
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(0)] [Priority(0)]
[NadekoOptionsAttribute(typeof(TriviaOptions))] [NadekoOptionsAttribute(typeof(TriviaOptions))]
public Task Trivia(params string[] args) public partial Task Trivia(params string[] args)
=> InternalTrivia(args); => InternalTrivia(args);
public async Task InternalTrivia(params string[] args) private async Task InternalTrivia(params string[] args)
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;
@@ -71,10 +70,9 @@ public partial class Games
await SendErrorAsync(GetText(strs.trivia_already_running) + "\n" + trivia.CurrentQuestion); await SendErrorAsync(GetText(strs.trivia_already_running) + "\n" + trivia.CurrentQuestion);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Tl() public async partial Task Tl()
{ {
if (_service.RunningTrivias.TryGetValue(ctx.Guild.Id, out var trivia)) if (_service.RunningTrivias.TryGetValue(ctx.Guild.Id, out var trivia))
{ {
@@ -85,10 +83,9 @@ public partial class Games
await ReplyErrorLocalizedAsync(strs.trivia_none); await ReplyErrorLocalizedAsync(strs.trivia_none);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Tq() public async partial Task Tq()
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;

View File

@@ -10,7 +10,7 @@ using JsonSerializer = System.Text.Json.JsonSerializer;
namespace NadekoBot.Modules.Help; namespace NadekoBot.Modules.Help;
public class Help : NadekoModule<HelpService> public partial class Help : NadekoModule<HelpService>
{ {
public const string PatreonUrl = "https://patreon.com/nadekobot"; public const string PatreonUrl = "https://patreon.com/nadekobot";
public const string PaypalUrl = "https://paypal.me/Kwoth"; public const string PaypalUrl = "https://paypal.me/Kwoth";
@@ -59,9 +59,8 @@ public class Help : NadekoModule<HelpService>
return r.Replace(text); return r.Replace(text);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Modules(int page = 1)
public async Task Modules(int page = 1)
{ {
if (--page < 0) if (--page < 0)
return; return;
@@ -162,10 +161,9 @@ public class Help : NadekoModule<HelpService>
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[NadekoOptions(typeof(CommandsOptions))] [NadekoOptions(typeof(CommandsOptions))]
public async Task Commands(string module = null, params string[] args) public async partial Task Commands(string module = null, params string[] args)
{ {
module = module?.Trim().ToUpperInvariant(); module = module?.Trim().ToUpperInvariant();
if (string.IsNullOrWhiteSpace(module)) if (string.IsNullOrWhiteSpace(module))
@@ -255,10 +253,9 @@ public class Help : NadekoModule<HelpService>
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[Priority(0)] [Priority(0)]
public async Task H([Leftover] string fail) public async partial Task H([Leftover] string fail)
{ {
var prefixless = var prefixless =
_cmds.Commands.FirstOrDefault(x => x.Aliases.Any(cmdName => cmdName.ToLowerInvariant() == fail)); _cmds.Commands.FirstOrDefault(x => x.Aliases.Any(cmdName => cmdName.ToLowerInvariant() == fail));
@@ -271,10 +268,9 @@ public class Help : NadekoModule<HelpService>
await ReplyErrorLocalizedAsync(strs.command_not_found); await ReplyErrorLocalizedAsync(strs.command_not_found);
} }
[NadekoCommand] [Cmd]
[Aliases]
[Priority(1)] [Priority(1)]
public async Task H([Leftover] CommandInfo com = null) public async partial Task H([Leftover] CommandInfo com = null)
{ {
var channel = ctx.Channel; var channel = ctx.Channel;
@@ -302,10 +298,9 @@ public class Help : NadekoModule<HelpService>
await channel.EmbedAsync(embed); await channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task GenCmdList() public async partial Task GenCmdList()
{ {
_ = ctx.Channel.TriggerTypingAsync(); _ = ctx.Channel.TriggerTypingAsync();
@@ -408,15 +403,13 @@ public class Help : NadekoModule<HelpService>
await ctx.Channel.SendFileAsync(rDataStream, "cmds.json", GetText(strs.commandlist_regen)); await ctx.Channel.SendFileAsync(rDataStream, "cmds.json", GetText(strs.commandlist_regen));
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Guide()
public async Task Guide()
=> await ConfirmLocalizedAsync(strs.guide("https://nadeko.bot/commands", => await ConfirmLocalizedAsync(strs.guide("https://nadeko.bot/commands",
"http://nadekobot.readthedocs.io/en/latest/")); "http://nadekobot.readthedocs.io/en/latest/"));
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Donate()
public async Task Donate()
=> await ReplyConfirmLocalizedAsync(strs.donate(PatreonUrl, PaypalUrl)); => await ReplyConfirmLocalizedAsync(strs.donate(PatreonUrl, PaypalUrl));
} }

View File

@@ -153,10 +153,9 @@ public sealed partial class Music : NadekoModule<IMusicService>
} }
// join vc // join vc
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Join() public async partial Task Join()
{ {
var user = (IGuildUser)ctx.User; var user = (IGuildUser)ctx.User;
@@ -172,10 +171,9 @@ public sealed partial class Music : NadekoModule<IMusicService>
} }
// leave vc (destroy) // leave vc (destroy)
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Destroy() public async partial Task Destroy()
{ {
var valid = await ValidateAsync(); var valid = await ValidateAsync();
if (!valid) if (!valid)
@@ -185,45 +183,39 @@ public sealed partial class Music : NadekoModule<IMusicService>
} }
// play - no args = next // play - no args = next
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(2)] [Priority(2)]
public Task Play() public partial Task Play()
=> Next(); => Next();
// play - index = skip to that index // play - index = skip to that index
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(1)] [Priority(1)]
public Task Play(int index) public partial Task Play(int index)
=> MoveToIndex(index); => MoveToIndex(index);
// play - query = q(query) // play - query = q(query)
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(0)] [Priority(0)]
public Task Play([Leftover] string query) public partial Task Play([Leftover] string query)
=> QueueByQuery(query); => QueueByQuery(query);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public Task Queue([Leftover] string query) public partial Task Queue([Leftover] string query)
=> QueueByQuery(query); => QueueByQuery(query);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public Task QueueNext([Leftover] string query) public partial Task QueueNext([Leftover] string query)
=> QueueByQuery(query, true); => QueueByQuery(query, true);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Volume(int vol) public async partial Task Volume(int vol)
{ {
if (vol is < 0 or > 100) if (vol is < 0 or > 100)
{ {
@@ -239,10 +231,9 @@ public sealed partial class Music : NadekoModule<IMusicService>
await ReplyConfirmLocalizedAsync(strs.volume_set(vol)); await ReplyConfirmLocalizedAsync(strs.volume_set(vol));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Next() public async partial Task Next()
{ {
var valid = await ValidateAsync(); var valid = await ValidateAsync();
if (!valid) if (!valid)
@@ -253,10 +244,9 @@ public sealed partial class Music : NadekoModule<IMusicService>
} }
// list queue, relevant page // list queue, relevant page
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task ListQueue() public async partial Task ListQueue()
{ {
// show page with the current song // show page with the current song
if (!_service.TryGetMusicPlayer(ctx.Guild.Id, out var mp)) if (!_service.TryGetMusicPlayer(ctx.Guild.Id, out var mp))
@@ -269,10 +259,9 @@ public sealed partial class Music : NadekoModule<IMusicService>
} }
// list queue, specify page // list queue, specify page
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task ListQueue(int page) public async partial Task ListQueue(int page)
{ {
if (--page < 0) if (--page < 0)
return; return;
@@ -341,10 +330,9 @@ public sealed partial class Music : NadekoModule<IMusicService>
} }
// search // search
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task QueueSearch([Leftover] string query) public async partial Task QueueSearch([Leftover] string query)
{ {
_ = ctx.Channel.TriggerTypingAsync(); _ = ctx.Channel.TriggerTypingAsync();
@@ -394,11 +382,10 @@ public sealed partial class Music : NadekoModule<IMusicService>
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(1)] [Priority(1)]
public async Task TrackRemove(int index) public async partial Task TrackRemove(int index)
{ {
if (index < 1) if (index < 1)
{ {
@@ -431,11 +418,10 @@ public sealed partial class Music : NadekoModule<IMusicService>
await _service.SendToOutputAsync(ctx.Guild.Id, embed); await _service.SendToOutputAsync(ctx.Guild.Id, embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(0)] [Priority(0)]
public async Task TrackRemove(All _ = All.All) public async partial Task TrackRemove(All _ = All.All)
{ {
var valid = await ValidateAsync(); var valid = await ValidateAsync();
if (!valid) if (!valid)
@@ -451,10 +437,9 @@ public sealed partial class Music : NadekoModule<IMusicService>
await ReplyConfirmLocalizedAsync(strs.queue_cleared); await ReplyConfirmLocalizedAsync(strs.queue_cleared);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Stop() public async partial Task Stop()
{ {
var valid = await ValidateAsync(); var valid = await ValidateAsync();
if (!valid) if (!valid)
@@ -478,10 +463,9 @@ public sealed partial class Music : NadekoModule<IMusicService>
_ => PlayerRepeatType.Queue _ => PlayerRepeatType.Queue
}; };
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task QueueRepeat(InputRepeatType type = InputRepeatType.Queue) public async partial Task QueueRepeat(InputRepeatType type = InputRepeatType.Queue)
{ {
var valid = await ValidateAsync(); var valid = await ValidateAsync();
if (!valid) if (!valid)
@@ -497,10 +481,9 @@ public sealed partial class Music : NadekoModule<IMusicService>
await ReplyConfirmLocalizedAsync(strs.repeating_track); await ReplyConfirmLocalizedAsync(strs.repeating_track);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Pause() public async partial Task Pause()
{ {
var valid = await ValidateAsync(); var valid = await ValidateAsync();
if (!valid) if (!valid)
@@ -515,24 +498,21 @@ public sealed partial class Music : NadekoModule<IMusicService>
mp.TogglePause(); mp.TogglePause();
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public Task Radio(string radioLink) public partial Task Radio(string radioLink)
=> QueueByQuery(radioLink, false, MusicPlatform.Radio); => QueueByQuery(radioLink, false, MusicPlatform.Radio);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[OwnerOnly] [OwnerOnly]
public Task Local([Leftover] string path) public partial Task Local([Leftover] string path)
=> QueueByQuery(path, false, MusicPlatform.Local); => QueueByQuery(path, false, MusicPlatform.Local);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[OwnerOnly] [OwnerOnly]
public async Task LocalPlaylist([Leftover] string dirPath) public async partial Task LocalPlaylist([Leftover] string dirPath)
{ {
if (string.IsNullOrWhiteSpace(dirPath)) if (string.IsNullOrWhiteSpace(dirPath))
return; return;
@@ -569,10 +549,9 @@ public sealed partial class Music : NadekoModule<IMusicService>
await ReplyConfirmLocalizedAsync(strs.dir_queue_complete); await ReplyConfirmLocalizedAsync(strs.dir_queue_complete);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task MoveSong(int from, int to) public async partial Task MoveSong(int from, int to)
{ {
if (--from < 0 || --to < 0 || from == to) if (--from < 0 || --to < 0 || from == to)
{ {
@@ -611,16 +590,14 @@ public sealed partial class Music : NadekoModule<IMusicService>
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public Task SoundCloudQueue([Leftover] string query) public partial Task SoundCloudQueue([Leftover] string query)
=> QueueByQuery(query, false, MusicPlatform.SoundCloud); => QueueByQuery(query, false, MusicPlatform.SoundCloud);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task SoundCloudPl([Leftover] string playlist) public async partial Task SoundCloudPl([Leftover] string playlist)
{ {
if (string.IsNullOrWhiteSpace(playlist)) if (string.IsNullOrWhiteSpace(playlist))
return; return;
@@ -643,10 +620,9 @@ public sealed partial class Music : NadekoModule<IMusicService>
await ctx.OkAsync(); await ctx.OkAsync();
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Playlist([Leftover] string playlistQuery) public async partial Task Playlist([Leftover] string playlistQuery)
{ {
if (string.IsNullOrWhiteSpace(playlistQuery)) if (string.IsNullOrWhiteSpace(playlistQuery))
return; return;
@@ -675,10 +651,9 @@ public sealed partial class Music : NadekoModule<IMusicService>
await ctx.OkAsync(); await ctx.OkAsync();
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task NowPlaying() public async partial Task NowPlaying()
{ {
var mp = await _service.GetOrCreateMusicPlayerAsync((ITextChannel)ctx.Channel); var mp = await _service.GetOrCreateMusicPlayerAsync((ITextChannel)ctx.Channel);
if (mp is null) if (mp is null)
@@ -702,10 +677,9 @@ public sealed partial class Music : NadekoModule<IMusicService>
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task PlaylistShuffle() public async partial Task PlaylistShuffle()
{ {
var valid = await ValidateAsync(); var valid = await ValidateAsync();
if (!valid) if (!valid)
@@ -722,32 +696,29 @@ public sealed partial class Music : NadekoModule<IMusicService>
await ReplyConfirmLocalizedAsync(strs.queue_shuffled); await ReplyConfirmLocalizedAsync(strs.queue_shuffled);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
public async Task SetMusicChannel() public async partial Task SetMusicChannel()
{ {
await _service.SetMusicChannelAsync(ctx.Guild.Id, ctx.Channel.Id); await _service.SetMusicChannelAsync(ctx.Guild.Id, ctx.Channel.Id);
await ReplyConfirmLocalizedAsync(strs.set_music_channel); await ReplyConfirmLocalizedAsync(strs.set_music_channel);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
public async Task UnsetMusicChannel() public async partial Task UnsetMusicChannel()
{ {
await _service.SetMusicChannelAsync(ctx.Guild.Id, null); await _service.SetMusicChannelAsync(ctx.Guild.Id, null);
await ReplyConfirmLocalizedAsync(strs.unset_music_channel); await ReplyConfirmLocalizedAsync(strs.unset_music_channel);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task AutoDisconnect() public async partial Task AutoDisconnect()
{ {
var newState = await _service.ToggleAutoDisconnectAsync(ctx.Guild.Id); var newState = await _service.ToggleAutoDisconnectAsync(ctx.Guild.Id);
@@ -757,21 +728,19 @@ public sealed partial class Music : NadekoModule<IMusicService>
await ReplyConfirmLocalizedAsync(strs.autodc_disable); await ReplyConfirmLocalizedAsync(strs.autodc_disable);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task MusicQuality() public async partial Task MusicQuality()
{ {
var quality = await _service.GetMusicQualityAsync(ctx.Guild.Id); var quality = await _service.GetMusicQualityAsync(ctx.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.current_music_quality(Format.Bold(quality.ToString()))); await ReplyConfirmLocalizedAsync(strs.current_music_quality(Format.Bold(quality.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task MusicQuality(QualityPreset preset) public async partial Task MusicQuality(QualityPreset preset)
{ {
await _service.SetMusicQualityAsync(ctx.Guild.Id, preset); await _service.SetMusicQualityAsync(ctx.Guild.Id, preset);
await ReplyConfirmLocalizedAsync(strs.music_quality_set(Format.Bold(preset.ToString()))); await ReplyConfirmLocalizedAsync(strs.music_quality_set(Format.Bold(preset.ToString())));

View File

@@ -8,7 +8,7 @@ namespace NadekoBot.Modules.Music;
public sealed partial class Music public sealed partial class Music
{ {
[Group] [Group]
public sealed class PlaylistCommands : NadekoModule<IMusicService> public sealed partial class PlaylistCommands : NadekoModule<IMusicService>
{ {
private static readonly SemaphoreSlim _playlistLock = new(1, 1); private static readonly SemaphoreSlim _playlistLock = new(1, 1);
private readonly DbService _db; private readonly DbService _db;
@@ -35,10 +35,9 @@ public sealed partial class Music
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Playlists([Leftover] int num = 1) public async partial Task Playlists([Leftover] int num = 1)
{ {
if (num <= 0) if (num <= 0)
return; return;
@@ -59,10 +58,9 @@ public sealed partial class Music
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task DeletePlaylist([Leftover] int id) public async partial Task DeletePlaylist([Leftover] int id)
{ {
var success = false; var success = false;
try try
@@ -89,10 +87,9 @@ public sealed partial class Music
await ReplyConfirmLocalizedAsync(strs.playlist_deleted); await ReplyConfirmLocalizedAsync(strs.playlist_deleted);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task PlaylistShow(int id, int page = 1) public async partial Task PlaylistShow(int id, int page = 1)
{ {
if (page-- < 1) if (page-- < 1)
return; return;
@@ -117,10 +114,9 @@ public sealed partial class Music
20); 20);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Save([Leftover] string name) public async partial Task Save([Leftover] string name)
{ {
if (!_service.TryGetMusicPlayer(ctx.Guild.Id, out var mp)) if (!_service.TryGetMusicPlayer(ctx.Guild.Id, out var mp))
{ {
@@ -156,10 +152,9 @@ public sealed partial class Music
.AddField(GetText(strs.id), playlist.Id.ToString())); .AddField(GetText(strs.id), playlist.Id.ToString()));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Load([Leftover] int id) public async partial Task Load([Leftover] int id)
{ {
// expensive action, 1 at a time // expensive action, 1 at a time
await _playlistLock.WaitAsync(); await _playlistLock.WaitAsync();

View File

@@ -5,7 +5,7 @@ using Newtonsoft.Json.Linq;
namespace NadekoBot.Modules.Nsfw; namespace NadekoBot.Modules.Nsfw;
[NoPublicBot] [NoPublicBot]
public class NSFW : NadekoModule<ISearchImagesService> public partial class NSFW : NadekoModule<ISearchImagesService>
{ {
private static readonly ConcurrentHashSet<ulong> _hentaiBombBlacklist = new(); private static readonly ConcurrentHashSet<ulong> _hentaiBombBlacklist = new();
private readonly IHttpClientFactory _httpFactory; private readonly IHttpClientFactory _httpFactory;
@@ -55,12 +55,11 @@ public class NSFW : NadekoModule<ISearchImagesService>
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireNsfw] [RequireNsfw]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(ChannelPerm.ManageMessages)] [UserPerm(ChannelPerm.ManageMessages)]
public async Task AutoHentai(int interval = 0, [Leftover] string tags = null) public async partial Task AutoHentai(int interval = 0, [Leftover] string tags = null)
{ {
Timer t; Timer t;
@@ -111,12 +110,11 @@ public class NSFW : NadekoModule<ISearchImagesService>
await ReplyConfirmLocalizedAsync(strs.autohentai_started(interval, string.Join(", ", tags))); await ReplyConfirmLocalizedAsync(strs.autohentai_started(interval, string.Join(", ", tags)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireNsfw] [RequireNsfw]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(ChannelPerm.ManageMessages)] [UserPerm(ChannelPerm.ManageMessages)]
public async Task AutoBoobs(int interval = 0) public async partial Task AutoBoobs(int interval = 0)
{ {
Timer t; Timer t;
@@ -158,12 +156,11 @@ public class NSFW : NadekoModule<ISearchImagesService>
await ReplyConfirmLocalizedAsync(strs.started(interval)); await ReplyConfirmLocalizedAsync(strs.started(interval));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireNsfw(Group = "nsfw_or_dm")] [RequireNsfw(Group = "nsfw_or_dm")]
[RequireContext(ContextType.DM, Group = "nsfw_or_dm")] [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
[UserPerm(ChannelPerm.ManageMessages)] [UserPerm(ChannelPerm.ManageMessages)]
public async Task AutoButts(int interval = 0) public async partial Task AutoButts(int interval = 0)
{ {
Timer t; Timer t;
@@ -205,18 +202,16 @@ public class NSFW : NadekoModule<ISearchImagesService>
await ReplyConfirmLocalizedAsync(strs.started(interval)); await ReplyConfirmLocalizedAsync(strs.started(interval));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireNsfw(Group = "nsfw_or_dm")] [RequireNsfw(Group = "nsfw_or_dm")]
[RequireContext(ContextType.DM, Group = "nsfw_or_dm")] [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
public Task Hentai(params string[] tags) public partial Task Hentai(params string[] tags)
=> InternalDapiCommand(tags, true, _service.Hentai); => InternalDapiCommand(tags, true, _service.Hentai);
[NadekoCommand] [Cmd]
[Aliases]
[RequireNsfw(Group = "nsfw_or_dm")] [RequireNsfw(Group = "nsfw_or_dm")]
[RequireContext(ContextType.DM, Group = "nsfw_or_dm")] [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
public async Task HentaiBomb(params string[] tags) public async partial Task HentaiBomb(params string[] tags)
{ {
if (!_hentaiBombBlacklist.Add(ctx.Guild?.Id ?? ctx.User.Id)) if (!_hentaiBombBlacklist.Add(ctx.Guild?.Id ?? ctx.User.Id))
return; return;
@@ -242,74 +237,64 @@ public class NSFW : NadekoModule<ISearchImagesService>
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireNsfw(Group = "nsfw_or_dm")] [RequireNsfw(Group = "nsfw_or_dm")]
[RequireContext(ContextType.DM, Group = "nsfw_or_dm")] [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
public Task Yandere(params string[] tags) public partial Task Yandere(params string[] tags)
=> InternalDapiCommand(tags, false, _service.Yandere); => InternalDapiCommand(tags, false, _service.Yandere);
[NadekoCommand] [Cmd]
[Aliases]
[RequireNsfw(Group = "nsfw_or_dm")] [RequireNsfw(Group = "nsfw_or_dm")]
[RequireContext(ContextType.DM, Group = "nsfw_or_dm")] [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
public Task Konachan(params string[] tags) public partial Task Konachan(params string[] tags)
=> InternalDapiCommand(tags, false, _service.Konachan); => InternalDapiCommand(tags, false, _service.Konachan);
[NadekoCommand] [Cmd]
[Aliases]
[RequireNsfw(Group = "nsfw_or_dm")] [RequireNsfw(Group = "nsfw_or_dm")]
[RequireContext(ContextType.DM, Group = "nsfw_or_dm")] [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
public Task Sankaku(params string[] tags) public partial Task Sankaku(params string[] tags)
=> InternalDapiCommand(tags, false, _service.Sankaku); => InternalDapiCommand(tags, false, _service.Sankaku);
[NadekoCommand] [Cmd]
[Aliases]
[RequireNsfw(Group = "nsfw_or_dm")] [RequireNsfw(Group = "nsfw_or_dm")]
[RequireContext(ContextType.DM, Group = "nsfw_or_dm")] [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
public Task E621(params string[] tags) public partial Task E621(params string[] tags)
=> InternalDapiCommand(tags, false, _service.E621); => InternalDapiCommand(tags, false, _service.E621);
[NadekoCommand] [Cmd]
[Aliases]
[RequireNsfw(Group = "nsfw_or_dm")] [RequireNsfw(Group = "nsfw_or_dm")]
[RequireContext(ContextType.DM, Group = "nsfw_or_dm")] [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
public Task Rule34(params string[] tags) public partial Task Rule34(params string[] tags)
=> InternalDapiCommand(tags, false, _service.Rule34); => InternalDapiCommand(tags, false, _service.Rule34);
[NadekoCommand] [Cmd]
[Aliases]
[RequireNsfw(Group = "nsfw_or_dm")] [RequireNsfw(Group = "nsfw_or_dm")]
[RequireContext(ContextType.DM, Group = "nsfw_or_dm")] [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
public Task Danbooru(params string[] tags) public partial Task Danbooru(params string[] tags)
=> InternalDapiCommand(tags, false, _service.Danbooru); => InternalDapiCommand(tags, false, _service.Danbooru);
[NadekoCommand] [Cmd]
[Aliases]
[RequireNsfw(Group = "nsfw_or_dm")] [RequireNsfw(Group = "nsfw_or_dm")]
[RequireContext(ContextType.DM, Group = "nsfw_or_dm")] [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
public Task Gelbooru(params string[] tags) public partial Task Gelbooru(params string[] tags)
=> InternalDapiCommand(tags, false, _service.Gelbooru); => InternalDapiCommand(tags, false, _service.Gelbooru);
[NadekoCommand] [Cmd]
[Aliases]
[RequireNsfw(Group = "nsfw_or_dm")] [RequireNsfw(Group = "nsfw_or_dm")]
[RequireContext(ContextType.DM, Group = "nsfw_or_dm")] [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
public Task Derpibooru(params string[] tags) public partial Task Derpibooru(params string[] tags)
=> InternalDapiCommand(tags, false, _service.DerpiBooru); => InternalDapiCommand(tags, false, _service.DerpiBooru);
[NadekoCommand] [Cmd]
[Aliases]
[RequireNsfw(Group = "nsfw_or_dm")] [RequireNsfw(Group = "nsfw_or_dm")]
[RequireContext(ContextType.DM, Group = "nsfw_or_dm")] [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
public Task Safebooru(params string[] tags) public partial Task Safebooru(params string[] tags)
=> InternalDapiCommand(tags, false, _service.SafeBooru); => InternalDapiCommand(tags, false, _service.SafeBooru);
[NadekoCommand] [Cmd]
[Aliases]
[RequireNsfw(Group = "nsfw_or_dm")] [RequireNsfw(Group = "nsfw_or_dm")]
[RequireContext(ContextType.DM, Group = "nsfw_or_dm")] [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
public async Task Boobs() public async partial Task Boobs()
{ {
try try
{ {
@@ -328,11 +313,10 @@ public class NSFW : NadekoModule<ISearchImagesService>
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireNsfw(Group = "nsfw_or_dm")] [RequireNsfw(Group = "nsfw_or_dm")]
[RequireContext(ContextType.DM, Group = "nsfw_or_dm")] [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
public async Task Butts() public async partial Task Butts()
{ {
try try
{ {
@@ -351,11 +335,10 @@ public class NSFW : NadekoModule<ISearchImagesService>
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
public async Task NsfwTagBlacklist([Leftover] string tag = null) public async partial Task NsfwTagBlacklist([Leftover] string tag = null)
{ {
if (string.IsNullOrWhiteSpace(tag)) if (string.IsNullOrWhiteSpace(tag))
{ {
@@ -374,13 +357,12 @@ public class NSFW : NadekoModule<ISearchImagesService>
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[RequireNsfw(Group = "nsfw_or_dm")] [RequireNsfw(Group = "nsfw_or_dm")]
[RequireContext(ContextType.DM, Group = "nsfw_or_dm")] [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
[Priority(1)] [Priority(1)]
public async Task Nhentai(uint id) public async partial Task Nhentai(uint id)
{ {
var g = await _service.GetNhentaiByIdAsync(id); var g = await _service.GetNhentaiByIdAsync(id);
@@ -393,13 +375,12 @@ public class NSFW : NadekoModule<ISearchImagesService>
await SendNhentaiGalleryInternalAsync(g); await SendNhentaiGalleryInternalAsync(g);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[RequireNsfw(Group = "nsfw_or_dm")] [RequireNsfw(Group = "nsfw_or_dm")]
[RequireContext(ContextType.DM, Group = "nsfw_or_dm")] [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
[Priority(0)] [Priority(0)]
public async Task Nhentai([Leftover] string query) public async partial Task Nhentai([Leftover] string query)
{ {
var g = await _service.GetNhentaiBySearchAsync(query); var g = await _service.GetNhentaiBySearchAsync(query);

View File

@@ -7,7 +7,7 @@ namespace NadekoBot.Modules.Permissions;
public partial class Permissions public partial class Permissions
{ {
[Group] [Group]
public class BlacklistCommands : NadekoSubmodule<BlacklistService> public partial class BlacklistCommands : NadekoSubmodule<BlacklistService>
{ {
private readonly DiscordSocketClient _client; private readonly DiscordSocketClient _client;
@@ -66,10 +66,9 @@ public partial class Permissions
10); 10);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task UserBlacklist(int page = 1) public partial Task UserBlacklist(int page = 1)
{ {
if (--page < 0) if (--page < 0)
return Task.CompletedTask; return Task.CompletedTask;
@@ -77,10 +76,9 @@ public partial class Permissions
return ListBlacklistInternal(GetText(strs.blacklisted_users), BlacklistType.User, page); return ListBlacklistInternal(GetText(strs.blacklisted_users), BlacklistType.User, page);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task ChannelBlacklist(int page = 1) public partial Task ChannelBlacklist(int page = 1)
{ {
if (--page < 0) if (--page < 0)
return Task.CompletedTask; return Task.CompletedTask;
@@ -88,10 +86,9 @@ public partial class Permissions
return ListBlacklistInternal(GetText(strs.blacklisted_channels), BlacklistType.Channel, page); return ListBlacklistInternal(GetText(strs.blacklisted_channels), BlacklistType.Channel, page);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task ServerBlacklist(int page = 1) public partial Task ServerBlacklist(int page = 1)
{ {
if (--page < 0) if (--page < 0)
return Task.CompletedTask; return Task.CompletedTask;
@@ -99,34 +96,29 @@ public partial class Permissions
return ListBlacklistInternal(GetText(strs.blacklisted_servers), BlacklistType.Server, page); return ListBlacklistInternal(GetText(strs.blacklisted_servers), BlacklistType.Server, page);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task UserBlacklist(AddRemove action, ulong id) public partial Task UserBlacklist(AddRemove action, ulong id)
=> Blacklist(action, id, BlacklistType.User); => Blacklist(action, id, BlacklistType.User);
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task UserBlacklist(AddRemove action, IUser usr) public partial Task UserBlacklist(AddRemove action, IUser usr)
=> Blacklist(action, usr.Id, BlacklistType.User); => Blacklist(action, usr.Id, BlacklistType.User);
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task ChannelBlacklist(AddRemove action, ulong id) public partial Task ChannelBlacklist(AddRemove action, ulong id)
=> Blacklist(action, id, BlacklistType.Channel); => Blacklist(action, id, BlacklistType.Channel);
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task ServerBlacklist(AddRemove action, ulong id) public partial Task ServerBlacklist(AddRemove action, ulong id)
=> Blacklist(action, id, BlacklistType.Server); => Blacklist(action, id, BlacklistType.Server);
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public Task ServerBlacklist(AddRemove action, IGuild guild) public partial Task ServerBlacklist(AddRemove action, IGuild guild)
=> Blacklist(action, guild.Id, BlacklistType.Server); => Blacklist(action, guild.Id, BlacklistType.Server);
private async Task Blacklist(AddRemove action, ulong id, BlacklistType type) private async Task Blacklist(AddRemove action, ulong id, BlacklistType type)

View File

@@ -10,7 +10,7 @@ namespace NadekoBot.Modules.Permissions;
public partial class Permissions public partial class Permissions
{ {
[Group] [Group]
public class CmdCdsCommands : NadekoSubmodule public partial class CmdCdsCommands : NadekoSubmodule
{ {
private ConcurrentDictionary<ulong, ConcurrentHashSet<CommandCooldown>> CommandCooldowns private ConcurrentDictionary<ulong, ConcurrentHashSet<CommandCooldown>> CommandCooldowns
=> _service.CommandCooldowns; => _service.CommandCooldowns;
@@ -27,10 +27,9 @@ public partial class Permissions
_db = db; _db = db;
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task CmdCooldown(CommandOrCrInfo command, int secs) public async partial Task CmdCooldown(CommandOrCrInfo command, int secs)
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;
if (secs is < 0 or > 3600) if (secs is < 0 or > 3600)
@@ -71,10 +70,9 @@ public partial class Permissions
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task AllCmdCooldowns() public async partial Task AllCmdCooldowns()
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;
var localSet = CommandCooldowns.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<CommandCooldown>()); var localSet = CommandCooldowns.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<CommandCooldown>());

View File

@@ -9,27 +9,25 @@ namespace NadekoBot.Modules.Permissions;
public partial class Permissions public partial class Permissions
{ {
[Group] [Group]
public class FilterCommands : NadekoSubmodule<FilterService> public partial class FilterCommands : NadekoSubmodule<FilterService>
{ {
private readonly DbService _db; private readonly DbService _db;
public FilterCommands(DbService db) public FilterCommands(DbService db)
=> _db = db; => _db = db;
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task FwClear() public async partial Task FwClear()
{ {
_service.ClearFilteredWords(ctx.Guild.Id); _service.ClearFilteredWords(ctx.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.fw_cleared); await ReplyConfirmLocalizedAsync(strs.fw_cleared);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task SrvrFilterInv() public async partial Task SrvrFilterInv()
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;
@@ -53,10 +51,9 @@ public partial class Permissions
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task ChnlFilterInv() public async partial Task ChnlFilterInv()
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;
@@ -87,10 +84,9 @@ public partial class Permissions
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task SrvrFilterLin() public async partial Task SrvrFilterLin()
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;
@@ -114,10 +110,9 @@ public partial class Permissions
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task ChnlFilterLin() public async partial Task ChnlFilterLin()
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;
@@ -148,10 +143,9 @@ public partial class Permissions
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task SrvrFilterWords() public async partial Task SrvrFilterWords()
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;
@@ -175,10 +169,9 @@ public partial class Permissions
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task ChnlFilterWords() public async partial Task ChnlFilterWords()
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;
@@ -209,10 +202,9 @@ public partial class Permissions
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task FilterWord([Leftover] string word) public async partial Task FilterWord([Leftover] string word)
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;
@@ -251,10 +243,9 @@ public partial class Permissions
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task LstFilterWords(int page = 1) public async partial Task LstFilterWords(int page = 1)
{ {
page--; page--;
if (page < 0) if (page < 0)

View File

@@ -7,7 +7,7 @@ namespace NadekoBot.Modules.Permissions;
public partial class Permissions public partial class Permissions
{ {
[Group] [Group]
public class GlobalPermissionCommands : NadekoSubmodule public partial class GlobalPermissionCommands : NadekoSubmodule
{ {
private GlobalPermissionService _service; private GlobalPermissionService _service;
private readonly DbService _db; private readonly DbService _db;
@@ -18,10 +18,9 @@ public partial class Permissions
_db = db; _db = db;
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task GlobalPermList() public async partial Task GlobalPermList()
{ {
var blockedModule = _service.BlockedModules; var blockedModule = _service.BlockedModules;
var blockedCommands = _service.BlockedCommands; var blockedCommands = _service.BlockedCommands;
@@ -42,10 +41,9 @@ public partial class Permissions
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task GlobalModule(ModuleOrCrInfo module) public async partial Task GlobalModule(ModuleOrCrInfo module)
{ {
var moduleName = module.Name.ToLowerInvariant(); var moduleName = module.Name.ToLowerInvariant();
@@ -60,10 +58,9 @@ public partial class Permissions
await ReplyConfirmLocalizedAsync(strs.gmod_remove(Format.Bold(module.Name))); await ReplyConfirmLocalizedAsync(strs.gmod_remove(Format.Bold(module.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task GlobalCommand(CommandOrCrInfo cmd) public async partial Task GlobalCommand(CommandOrCrInfo cmd)
{ {
var commandName = cmd.Name.ToLowerInvariant(); var commandName = cmd.Name.ToLowerInvariant();
var added = _service.ToggleCommand(commandName); var added = _service.ToggleCommand(commandName);

View File

@@ -17,10 +17,9 @@ public partial class Permissions : NadekoModule<PermissionService>
public Permissions(DbService db) public Permissions(DbService db)
=> _db = db; => _db = db;
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Verbose(PermissionAction action = null) public async partial Task Verbose(PermissionAction action = null)
{ {
await using (var uow = _db.GetDbContext()) await using (var uow = _db.GetDbContext())
{ {
@@ -37,12 +36,11 @@ public partial class Permissions : NadekoModule<PermissionService>
await ReplyConfirmLocalizedAsync(strs.verbose_false); await ReplyConfirmLocalizedAsync(strs.verbose_false);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[Priority(0)] [Priority(0)]
public async Task PermRole([Leftover] IRole role = null) public async partial Task PermRole([Leftover] IRole role = null)
{ {
if (role != null && role == role.Guild.EveryoneRole) if (role != null && role == role.Guild.EveryoneRole)
return; return;
@@ -69,12 +67,11 @@ public partial class Permissions : NadekoModule<PermissionService>
await ReplyConfirmLocalizedAsync(strs.permrole_changed(Format.Bold(role.Name))); await ReplyConfirmLocalizedAsync(strs.permrole_changed(Format.Bold(role.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[Priority(1)] [Priority(1)]
public async Task PermRole(Reset _) public async partial Task PermRole(Reset _)
{ {
await using (var uow = _db.GetDbContext()) await using (var uow = _db.GetDbContext())
{ {
@@ -87,10 +84,9 @@ public partial class Permissions : NadekoModule<PermissionService>
await ReplyConfirmLocalizedAsync(strs.permrole_reset); await ReplyConfirmLocalizedAsync(strs.permrole_reset);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task ListPerms(int page = 1) public async partial Task ListPerms(int page = 1)
{ {
if (page < 1) if (page < 1)
return; return;
@@ -121,10 +117,9 @@ public partial class Permissions : NadekoModule<PermissionService>
await ctx.Channel.SendMessageAsync(toSend); await ctx.Channel.SendMessageAsync(toSend);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task RemovePerm(int index) public async partial Task RemovePerm(int index)
{ {
index -= 1; index -= 1;
if (index < 0) if (index < 0)
@@ -152,10 +147,9 @@ public partial class Permissions : NadekoModule<PermissionService>
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task MovePerm(int from, int to) public async partial Task MovePerm(int from, int to)
{ {
from -= 1; from -= 1;
to -= 1; to -= 1;
@@ -205,10 +199,9 @@ public partial class Permissions : NadekoModule<PermissionService>
await ReplyConfirmLocalizedAsync(strs.perm_out_of_range); await ReplyConfirmLocalizedAsync(strs.perm_out_of_range);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task SrvrCmd(CommandOrCrInfo command, PermissionAction action) public async partial Task SrvrCmd(CommandOrCrInfo command, PermissionAction action)
{ {
await _service.AddPermissions(ctx.Guild.Id, await _service.AddPermissions(ctx.Guild.Id,
new Permissionv2 new Permissionv2
@@ -227,10 +220,9 @@ public partial class Permissions : NadekoModule<PermissionService>
await ReplyConfirmLocalizedAsync(strs.sx_disable(Format.Code(command.Name), GetText(strs.of_command))); await ReplyConfirmLocalizedAsync(strs.sx_disable(Format.Code(command.Name), GetText(strs.of_command)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task SrvrMdl(ModuleOrCrInfo module, PermissionAction action) public async partial Task SrvrMdl(ModuleOrCrInfo module, PermissionAction action)
{ {
await _service.AddPermissions(ctx.Guild.Id, await _service.AddPermissions(ctx.Guild.Id,
new Permissionv2 new Permissionv2
@@ -248,10 +240,9 @@ public partial class Permissions : NadekoModule<PermissionService>
await ReplyConfirmLocalizedAsync(strs.sx_disable(Format.Code(module.Name), GetText(strs.of_module))); await ReplyConfirmLocalizedAsync(strs.sx_disable(Format.Code(module.Name), GetText(strs.of_module)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task UsrCmd(CommandOrCrInfo command, PermissionAction action, [Leftover] IGuildUser user) public async partial Task UsrCmd(CommandOrCrInfo command, PermissionAction action, [Leftover] IGuildUser user)
{ {
await _service.AddPermissions(ctx.Guild.Id, await _service.AddPermissions(ctx.Guild.Id,
new Permissionv2 new Permissionv2
@@ -274,10 +265,9 @@ public partial class Permissions : NadekoModule<PermissionService>
Format.Code(user.ToString()))); Format.Code(user.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task UsrMdl(ModuleOrCrInfo module, PermissionAction action, [Leftover] IGuildUser user) public async partial Task UsrMdl(ModuleOrCrInfo module, PermissionAction action, [Leftover] IGuildUser user)
{ {
await _service.AddPermissions(ctx.Guild.Id, await _service.AddPermissions(ctx.Guild.Id,
new Permissionv2 new Permissionv2
@@ -299,10 +289,9 @@ public partial class Permissions : NadekoModule<PermissionService>
Format.Code(user.ToString()))); Format.Code(user.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task RoleCmd(CommandOrCrInfo command, PermissionAction action, [Leftover] IRole role) public async partial Task RoleCmd(CommandOrCrInfo command, PermissionAction action, [Leftover] IRole role)
{ {
if (role == role.Guild.EveryoneRole) if (role == role.Guild.EveryoneRole)
return; return;
@@ -328,10 +317,9 @@ public partial class Permissions : NadekoModule<PermissionService>
Format.Code(role.Name))); Format.Code(role.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task RoleMdl(ModuleOrCrInfo module, PermissionAction action, [Leftover] IRole role) public async partial Task RoleMdl(ModuleOrCrInfo module, PermissionAction action, [Leftover] IRole role)
{ {
if (role == role.Guild.EveryoneRole) if (role == role.Guild.EveryoneRole)
return; return;
@@ -357,10 +345,9 @@ public partial class Permissions : NadekoModule<PermissionService>
Format.Code(role.Name))); Format.Code(role.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task ChnlCmd(CommandOrCrInfo command, PermissionAction action, [Leftover] ITextChannel chnl) public async partial Task ChnlCmd(CommandOrCrInfo command, PermissionAction action, [Leftover] ITextChannel chnl)
{ {
await _service.AddPermissions(ctx.Guild.Id, await _service.AddPermissions(ctx.Guild.Id,
new Permissionv2 new Permissionv2
@@ -383,10 +370,9 @@ public partial class Permissions : NadekoModule<PermissionService>
Format.Code(chnl.Name))); Format.Code(chnl.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task ChnlMdl(ModuleOrCrInfo module, PermissionAction action, [Leftover] ITextChannel chnl) public async partial Task ChnlMdl(ModuleOrCrInfo module, PermissionAction action, [Leftover] ITextChannel chnl)
{ {
await _service.AddPermissions(ctx.Guild.Id, await _service.AddPermissions(ctx.Guild.Id,
new Permissionv2 new Permissionv2
@@ -408,10 +394,9 @@ public partial class Permissions : NadekoModule<PermissionService>
Format.Code(chnl.Name))); Format.Code(chnl.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task AllChnlMdls(PermissionAction action, [Leftover] ITextChannel chnl) public async partial Task AllChnlMdls(PermissionAction action, [Leftover] ITextChannel chnl)
{ {
await _service.AddPermissions(ctx.Guild.Id, await _service.AddPermissions(ctx.Guild.Id,
new Permissionv2 new Permissionv2
@@ -429,10 +414,9 @@ public partial class Permissions : NadekoModule<PermissionService>
await ReplyConfirmLocalizedAsync(strs.acm_disable(Format.Code(chnl.Name))); await ReplyConfirmLocalizedAsync(strs.acm_disable(Format.Code(chnl.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task AllRoleMdls(PermissionAction action, [Leftover] IRole role) public async partial Task AllRoleMdls(PermissionAction action, [Leftover] IRole role)
{ {
if (role == role.Guild.EveryoneRole) if (role == role.Guild.EveryoneRole)
return; return;
@@ -453,10 +437,9 @@ public partial class Permissions : NadekoModule<PermissionService>
await ReplyConfirmLocalizedAsync(strs.arm_disable(Format.Code(role.Name))); await ReplyConfirmLocalizedAsync(strs.arm_disable(Format.Code(role.Name)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task AllUsrMdls(PermissionAction action, [Leftover] IUser user) public async partial Task AllUsrMdls(PermissionAction action, [Leftover] IUser user)
{ {
await _service.AddPermissions(ctx.Guild.Id, await _service.AddPermissions(ctx.Guild.Id,
new Permissionv2 new Permissionv2
@@ -474,10 +457,9 @@ public partial class Permissions : NadekoModule<PermissionService>
await ReplyConfirmLocalizedAsync(strs.aum_disable(Format.Code(user.ToString()))); await ReplyConfirmLocalizedAsync(strs.aum_disable(Format.Code(user.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task AllSrvrMdls(PermissionAction action) public async partial Task AllSrvrMdls(PermissionAction action)
{ {
var newPerm = new Permissionv2 var newPerm = new Permissionv2
{ {

View File

@@ -6,7 +6,7 @@ namespace NadekoBot.Modules.Permissions;
public partial class Permissions public partial class Permissions
{ {
[Group] [Group]
public class ResetPermissionsCommands : NadekoSubmodule public partial class ResetPermissionsCommands : NadekoSubmodule
{ {
private readonly GlobalPermissionService _gps; private readonly GlobalPermissionService _gps;
private readonly PermissionService _perms; private readonly PermissionService _perms;
@@ -17,20 +17,18 @@ public partial class Permissions
_perms = perms; _perms = perms;
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task ResetPerms() public async partial Task ResetPerms()
{ {
await _perms.Reset(ctx.Guild.Id); await _perms.Reset(ctx.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.perms_reset); await ReplyConfirmLocalizedAsync(strs.perms_reset);
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task ResetGlobalPerms() public async partial Task ResetGlobalPerms()
{ {
await _gps.Reset(); await _gps.Reset();
await ReplyConfirmLocalizedAsync(strs.global_perms_reset); await ReplyConfirmLocalizedAsync(strs.global_perms_reset);

View File

@@ -8,7 +8,7 @@ namespace NadekoBot.Modules.Searches;
public partial class Searches public partial class Searches
{ {
[Group] [Group]
public class AnimeSearchCommands : NadekoSubmodule<AnimeSearchService> public partial class AnimeSearchCommands : NadekoSubmodule<AnimeSearchService>
{ {
// [NadekoCommand, Aliases] // [NadekoCommand, Aliases]
// public async Task Novel([Leftover] string query) // public async Task Novel([Leftover] string query)
@@ -38,8 +38,7 @@ public partial class Searches
// await ctx.Channel.EmbedAsync(embed); // await ctx.Channel.EmbedAsync(embed);
// } // }
[NadekoCommand] [NadekoCommand, Aliases]
[Aliases]
[Priority(0)] [Priority(0)]
public async Task Mal([Leftover] string name) public async Task Mal([Leftover] string name)
{ {
@@ -130,16 +129,14 @@ public partial class Searches
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(1)] [Priority(1)]
public Task Mal(IGuildUser usr) public partial Task Mal(IGuildUser usr)
=> Mal(usr.Username); => Mal(usr.Username);
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Anime([Leftover] string query)
public async Task Anime([Leftover] string query)
{ {
if (string.IsNullOrWhiteSpace(query)) if (string.IsNullOrWhiteSpace(query))
return; return;
@@ -169,10 +166,9 @@ public partial class Searches
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Manga([Leftover] string query) public async partial Task Manga([Leftover] string query)
{ {
if (string.IsNullOrWhiteSpace(query)) if (string.IsNullOrWhiteSpace(query))
return; return;

View File

@@ -5,11 +5,10 @@ namespace NadekoBot.Modules.Searches;
public partial class Searches public partial class Searches
{ {
public class CryptoCommands : NadekoSubmodule<CryptoService> public partial class CryptoCommands : NadekoSubmodule<CryptoService>
{ {
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Crypto(string name)
public async Task Crypto(string name)
{ {
name = name?.ToUpperInvariant(); name = name?.ToUpperInvariant();

View File

@@ -8,16 +8,15 @@ namespace NadekoBot.Modules.Searches;
public partial class Searches public partial class Searches
{ {
[Group] [Group]
public class FeedCommands : NadekoSubmodule<FeedsService> public partial class FeedCommands : NadekoSubmodule<FeedsService>
{ {
private static readonly Regex YtChannelRegex = private static readonly Regex YtChannelRegex =
new(@"youtube\.com\/(?:c\/|channel\/|user\/)?(?<channelid>[a-zA-Z0-9\-]{1,})"); new(@"youtube\.com\/(?:c\/|channel\/|user\/)?(?<channelid>[a-zA-Z0-9\-]{1,})");
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
public Task YtUploadNotif(string url, [Leftover] ITextChannel channel = null) public partial Task YtUploadNotif(string url, [Leftover] ITextChannel channel = null)
{ {
var m = YtChannelRegex.Match(url); var m = YtChannelRegex.Match(url);
if (!m.Success) return ReplyErrorLocalizedAsync(strs.invalid_input); if (!m.Success) return ReplyErrorLocalizedAsync(strs.invalid_input);
@@ -27,11 +26,10 @@ public partial class Searches
return Feed("https://www.youtube.com/feeds/videos.xml?channel_id=" + channelId, channel); return Feed("https://www.youtube.com/feeds/videos.xml?channel_id=" + channelId, channel);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
public async Task Feed(string url, [Leftover] ITextChannel channel = null) public async partial Task Feed(string url, [Leftover] ITextChannel channel = null)
{ {
var success = Uri.TryCreate(url, UriKind.Absolute, out var uri) var success = Uri.TryCreate(url, UriKind.Absolute, out var uri)
&& (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps); && (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps);
@@ -62,11 +60,10 @@ public partial class Searches
await ReplyConfirmLocalizedAsync(strs.feed_not_valid); await ReplyConfirmLocalizedAsync(strs.feed_not_valid);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
public async Task FeedRemove(int index) public async partial Task FeedRemove(int index)
{ {
if (_service.RemoveFeed(ctx.Guild.Id, --index)) if (_service.RemoveFeed(ctx.Guild.Id, --index))
await ReplyConfirmLocalizedAsync(strs.feed_removed); await ReplyConfirmLocalizedAsync(strs.feed_removed);
@@ -74,11 +71,10 @@ public partial class Searches
await ReplyErrorLocalizedAsync(strs.feed_out_of_range); await ReplyErrorLocalizedAsync(strs.feed_out_of_range);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
public async Task FeedList() public async partial Task FeedList()
{ {
var feeds = _service.GetFeeds(ctx.Guild.Id); var feeds = _service.GetFeeds(ctx.Guild.Id);

View File

@@ -6,29 +6,25 @@ namespace NadekoBot.Modules.Searches;
public partial class Searches public partial class Searches
{ {
[Group] [Group]
public class JokeCommands : NadekoSubmodule<SearchesService> public partial class JokeCommands : NadekoSubmodule<SearchesService>
{ {
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Yomama()
public async Task Yomama()
=> await SendConfirmAsync(await _service.GetYomamaJoke()); => await SendConfirmAsync(await _service.GetYomamaJoke());
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Randjoke()
public async Task Randjoke()
{ {
var (setup, punchline) = await _service.GetRandomJoke(); var (setup, punchline) = await _service.GetRandomJoke();
await SendConfirmAsync(setup, punchline); await SendConfirmAsync(setup, punchline);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task ChuckNorris()
public async Task ChuckNorris()
=> await SendConfirmAsync(await _service.GetChuckNorrisJoke()); => await SendConfirmAsync(await _service.GetChuckNorrisJoke());
[NadekoCommand] [Cmd]
[Aliases] public async partial Task WowJoke()
public async Task WowJoke()
{ {
if (!_service.WowJokes.Any()) if (!_service.WowJokes.Any())
{ {
@@ -40,9 +36,8 @@ public partial class Searches
await SendConfirmAsync(joke.Question, joke.Answer); await SendConfirmAsync(joke.Question, joke.Answer);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task MagicItem()
public async Task MagicItem()
{ {
if (!_service.WowJokes.Any()) if (!_service.WowJokes.Any())
{ {

View File

@@ -8,7 +8,7 @@ namespace NadekoBot.Modules.Searches;
public partial class Searches public partial class Searches
{ {
[Group] [Group]
public class MemegenCommands : NadekoSubmodule public partial class MemegenCommands : NadekoSubmodule
{ {
private static readonly ImmutableDictionary<char, string> _map = new Dictionary<char, string> private static readonly ImmutableDictionary<char, string> _map = new Dictionary<char, string>
{ {
@@ -27,9 +27,8 @@ public partial class Searches
public MemegenCommands(IHttpClientFactory factory) public MemegenCommands(IHttpClientFactory factory)
=> _httpFactory = factory; => _httpFactory = factory;
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Memelist(int page = 1)
public async Task Memelist(int page = 1)
{ {
if (--page < 0) if (--page < 0)
return; return;
@@ -55,9 +54,8 @@ public partial class Searches
15); 15);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Memegen(string meme, [Leftover] string memeText = null)
public async Task Memegen(string meme, [Leftover] string memeText = null)
{ {
var memeUrl = $"http://api.memegen.link/{meme}"; var memeUrl = $"http://api.memegen.link/{meme}";
if (!string.IsNullOrWhiteSpace(memeText)) if (!string.IsNullOrWhiteSpace(memeText))

View File

@@ -7,7 +7,7 @@ namespace NadekoBot.Modules.Searches;
public partial class Searches public partial class Searches
{ {
[Group] [Group]
public class OsuCommands : NadekoSubmodule public partial class OsuCommands : NadekoSubmodule
{ {
private readonly IBotCredentials _creds; private readonly IBotCredentials _creds;
private readonly IHttpClientFactory _httpFactory; private readonly IHttpClientFactory _httpFactory;
@@ -18,9 +18,8 @@ public partial class Searches
_httpFactory = factory; _httpFactory = factory;
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Osu(string user, [Leftover] string mode = null)
public async Task Osu(string user, [Leftover] string mode = null)
{ {
if (string.IsNullOrWhiteSpace(user)) if (string.IsNullOrWhiteSpace(user))
return; return;
@@ -75,9 +74,8 @@ public partial class Searches
} }
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Gatari(string user, [Leftover] string mode = null)
public async Task Gatari(string user, [Leftover] string mode = null)
{ {
using var http = _httpFactory.CreateClient(); using var http = _httpFactory.CreateClient();
var modeNumber = string.IsNullOrWhiteSpace(mode) ? 0 : ResolveGameMode(mode); var modeNumber = string.IsNullOrWhiteSpace(mode) ? 0 : ResolveGameMode(mode);
@@ -114,9 +112,8 @@ public partial class Searches
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Osu5(string user, [Leftover] string mode = null)
public async Task Osu5(string user, [Leftover] string mode = null)
{ {
; ;
if (string.IsNullOrWhiteSpace(_creds.OsuApiKey)) if (string.IsNullOrWhiteSpace(_creds.OsuApiKey))

View File

@@ -12,7 +12,7 @@ namespace NadekoBot.Modules.Searches;
public partial class Searches public partial class Searches
{ {
[Group] [Group]
public class PathOfExileCommands : NadekoSubmodule<SearchesService> public partial class PathOfExileCommands : NadekoSubmodule<SearchesService>
{ {
private const string _poeURL = "https://www.pathofexile.com/character-window/get-characters?accountName="; private const string _poeURL = "https://www.pathofexile.com/character-window/get-characters?accountName=";
private const string _ponURL = "http://poe.ninja/api/Data/GetCurrencyOverview?league="; private const string _ponURL = "http://poe.ninja/api/Data/GetCurrencyOverview?league=";
@@ -114,9 +114,8 @@ public partial class Searches
public PathOfExileCommands(IHttpClientFactory httpFactory) public PathOfExileCommands(IHttpClientFactory httpFactory)
=> _httpFactory = httpFactory; => _httpFactory = httpFactory;
[NadekoCommand] [Cmd]
[Aliases] public async partial Task PathOfExile(string usr, string league = "", int page = 1)
public async Task PathOfExile(string usr, string league = "", int page = 1)
{ {
if (--page < 0) if (--page < 0)
return; return;
@@ -177,9 +176,8 @@ public partial class Searches
9); 9);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task PathOfExileLeagues()
public async Task PathOfExileLeagues()
{ {
var leagues = new List<Leagues>(); var leagues = new List<Leagues>();
@@ -219,9 +217,8 @@ public partial class Searches
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task PathOfExileCurrency(string leagueName, string currencyName, string convertName = "Chaos Orb")
public async Task PathOfExileCurrency(string leagueName, string currencyName, string convertName = "Chaos Orb")
{ {
if (string.IsNullOrWhiteSpace(leagueName)) if (string.IsNullOrWhiteSpace(leagueName))
{ {

View File

@@ -4,7 +4,7 @@ namespace NadekoBot.Modules.Searches;
public partial class Searches public partial class Searches
{ {
[Group] [Group]
public class PlaceCommands : NadekoSubmodule public partial class PlaceCommands : NadekoSubmodule
{ {
public enum PlaceType public enum PlaceType
{ {
@@ -20,14 +20,12 @@ public partial class Searches
private static readonly string _typesStr = string.Join(", ", Enum.GetNames(typeof(PlaceType))); private static readonly string _typesStr = string.Join(", ", Enum.GetNames(typeof(PlaceType)));
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Placelist()
public async Task Placelist()
=> await SendConfirmAsync(GetText(strs.list_of_place_tags(Prefix)), _typesStr); => await SendConfirmAsync(GetText(strs.list_of_place_tags(Prefix)), _typesStr);
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Place(PlaceType placeType, uint width = 0, uint height = 0)
public async Task Place(PlaceType placeType, uint width = 0, uint height = 0)
{ {
var url = string.Empty; var url = string.Empty;
switch (placeType) switch (placeType)

View File

@@ -7,7 +7,7 @@ namespace NadekoBot.Modules.Searches;
public partial class Searches public partial class Searches
{ {
[Group] [Group]
public class PokemonSearchCommands : NadekoSubmodule<SearchesService> public partial class PokemonSearchCommands : NadekoSubmodule<SearchesService>
{ {
public IReadOnlyDictionary<string, SearchPokemon> Pokemons public IReadOnlyDictionary<string, SearchPokemon> Pokemons
=> _cache.LocalData.Pokemons; => _cache.LocalData.Pokemons;
@@ -20,9 +20,8 @@ public partial class Searches
public PokemonSearchCommands(IDataCache cache) public PokemonSearchCommands(IDataCache cache)
=> _cache = cache; => _cache = cache;
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Pokemon([Leftover] string pokemon = null)
public async Task Pokemon([Leftover] string pokemon = null)
{ {
pokemon = pokemon?.Trim().ToUpperInvariant(); pokemon = pokemon?.Trim().ToUpperInvariant();
if (string.IsNullOrWhiteSpace(pokemon)) if (string.IsNullOrWhiteSpace(pokemon))
@@ -51,9 +50,8 @@ public partial class Searches
await ReplyErrorLocalizedAsync(strs.pokemon_none); await ReplyErrorLocalizedAsync(strs.pokemon_none);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task PokemonAbility([Leftover] string ability = null)
public async Task PokemonAbility([Leftover] string ability = null)
{ {
ability = ability?.Trim().ToUpperInvariant().Replace(" ", "", StringComparison.InvariantCulture); ability = ability?.Trim().ToUpperInvariant().Replace(" ", "", StringComparison.InvariantCulture);
if (string.IsNullOrWhiteSpace(ability)) if (string.IsNullOrWhiteSpace(ability))

View File

@@ -40,9 +40,8 @@ public partial class Searches : NadekoModule<SearchesService>
_tzSvc = tzSvc; _tzSvc = tzSvc;
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Rip([Leftover] IGuildUser usr)
public async Task Rip([Leftover] IGuildUser usr)
{ {
var av = usr.RealAvatarUrl(); var av = usr.RealAvatarUrl();
if (av is null) if (av is null)
@@ -53,9 +52,8 @@ public partial class Searches : NadekoModule<SearchesService>
$"Rip {Format.Bold(usr.ToString())} \n\t- " + Format.Italics(ctx.User.ToString())); $"Rip {Format.Bold(usr.ToString())} \n\t- " + Format.Italics(ctx.User.ToString()));
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Weather([Leftover] string query)
public async Task Weather([Leftover] string query)
{ {
if (!await ValidateQuery(query)) if (!await ValidateQuery(query))
return; return;
@@ -104,9 +102,8 @@ public partial class Searches : NadekoModule<SearchesService>
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Time([Leftover] string query)
public async Task Time([Leftover] string query)
{ {
if (!await ValidateQuery(query)) if (!await ValidateQuery(query))
return; return;
@@ -153,9 +150,8 @@ public partial class Searches : NadekoModule<SearchesService>
await ctx.Channel.SendMessageAsync(embed: eb.Build()); await ctx.Channel.SendMessageAsync(embed: eb.Build());
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Youtube([Leftover] string query = null)
public async Task Youtube([Leftover] string query = null)
{ {
if (!await ValidateQuery(query)) if (!await ValidateQuery(query))
return; return;
@@ -170,9 +166,8 @@ public partial class Searches : NadekoModule<SearchesService>
await ctx.Channel.SendMessageAsync(result); await ctx.Channel.SendMessageAsync(result);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Movie([Leftover] string query = null)
public async Task Movie([Leftover] string query = null)
{ {
if (!await ValidateQuery(query)) if (!await ValidateQuery(query))
return; return;
@@ -197,24 +192,20 @@ public partial class Searches : NadekoModule<SearchesService>
.WithImageUrl(movie.Poster)); .WithImageUrl(movie.Poster));
} }
[NadekoCommand] [Cmd]
[Aliases] public partial Task RandomCat()
public Task RandomCat()
=> InternalRandomImage(SearchesService.ImageTag.Cats); => InternalRandomImage(SearchesService.ImageTag.Cats);
[NadekoCommand] [Cmd]
[Aliases] public partial Task RandomDog()
public Task RandomDog()
=> InternalRandomImage(SearchesService.ImageTag.Dogs); => InternalRandomImage(SearchesService.ImageTag.Dogs);
[NadekoCommand] [Cmd]
[Aliases] public partial Task RandomFood()
public Task RandomFood()
=> InternalRandomImage(SearchesService.ImageTag.Food); => InternalRandomImage(SearchesService.ImageTag.Food);
[NadekoCommand] [Cmd]
[Aliases] public partial Task RandomBird()
public Task RandomBird()
=> InternalRandomImage(SearchesService.ImageTag.Birds); => InternalRandomImage(SearchesService.ImageTag.Birds);
private Task InternalRandomImage(SearchesService.ImageTag tag) private Task InternalRandomImage(SearchesService.ImageTag tag)
@@ -223,9 +214,8 @@ public partial class Searches : NadekoModule<SearchesService>
return ctx.Channel.EmbedAsync(_eb.Create().WithOkColor().WithImageUrl(url)); return ctx.Channel.EmbedAsync(_eb.Create().WithOkColor().WithImageUrl(url));
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Image([Leftover] string query = null)
public async Task Image([Leftover] string query = null)
{ {
var oterms = query?.Trim(); var oterms = query?.Trim();
if (!await ValidateQuery(query)) if (!await ValidateQuery(query))
@@ -277,9 +267,8 @@ public partial class Searches : NadekoModule<SearchesService>
} }
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Lmgtfy([Leftover] string ffs = null)
public async Task Lmgtfy([Leftover] string ffs = null)
{ {
if (!await ValidateQuery(ffs)) if (!await ValidateQuery(ffs))
return; return;
@@ -288,9 +277,8 @@ public partial class Searches : NadekoModule<SearchesService>
await SendConfirmAsync($"<{shortenedUrl}>"); await SendConfirmAsync($"<{shortenedUrl}>");
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Shorten([Leftover] string query)
public async Task Shorten([Leftover] string query)
{ {
if (!await ValidateQuery(query)) if (!await ValidateQuery(query))
return; return;
@@ -327,9 +315,8 @@ public partial class Searches : NadekoModule<SearchesService>
.AddField(GetText(strs.short_url), $"<{shortLink}>")); .AddField(GetText(strs.short_url), $"<{shortLink}>"));
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Google([Leftover] string query = null)
public async Task Google([Leftover] string query = null)
{ {
query = query?.Trim(); query = query?.Trim();
if (!await ValidateQuery(query)) if (!await ValidateQuery(query))
@@ -360,9 +347,8 @@ public partial class Searches : NadekoModule<SearchesService>
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task DuckDuckGo([Leftover] string query = null)
public async Task DuckDuckGo([Leftover] string query = null)
{ {
query = query?.Trim(); query = query?.Trim();
if (!await ValidateQuery(query)) if (!await ValidateQuery(query))
@@ -392,9 +378,8 @@ public partial class Searches : NadekoModule<SearchesService>
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task MagicTheGathering([Leftover] string search)
public async Task MagicTheGathering([Leftover] string search)
{ {
if (!await ValidateQuery(search)) if (!await ValidateQuery(search))
return; return;
@@ -420,9 +405,8 @@ public partial class Searches : NadekoModule<SearchesService>
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Hearthstone([Leftover] string name)
public async Task Hearthstone([Leftover] string name)
{ {
var arg = name; var arg = name;
if (!await ValidateQuery(name)) if (!await ValidateQuery(name))
@@ -451,9 +435,8 @@ public partial class Searches : NadekoModule<SearchesService>
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task UrbanDict([Leftover] string query = null)
public async Task UrbanDict([Leftover] string query = null)
{ {
if (!await ValidateQuery(query)) if (!await ValidateQuery(query))
return; return;
@@ -491,9 +474,8 @@ public partial class Searches : NadekoModule<SearchesService>
await ReplyErrorLocalizedAsync(strs.ud_error); await ReplyErrorLocalizedAsync(strs.ud_error);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Define([Leftover] string word)
public async Task Define([Leftover] string word)
{ {
if (!await ValidateQuery(word)) if (!await ValidateQuery(word))
return; return;
@@ -562,9 +544,8 @@ public partial class Searches : NadekoModule<SearchesService>
} }
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Catfact()
public async Task Catfact()
{ {
using var http = _httpFactory.CreateClient(); using var http = _httpFactory.CreateClient();
var response = await http.GetStringAsync("https://catfact.ninja/fact"); var response = await http.GetStringAsync("https://catfact.ninja/fact");
@@ -576,10 +557,9 @@ public partial class Searches : NadekoModule<SearchesService>
} }
//done in 3.0 //done in 3.0
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Revav([Leftover] IGuildUser usr = null) public async partial Task Revav([Leftover] IGuildUser usr = null)
{ {
if (usr is null) if (usr is null)
usr = (IGuildUser)ctx.User; usr = (IGuildUser)ctx.User;
@@ -592,9 +572,8 @@ public partial class Searches : NadekoModule<SearchesService>
} }
//done in 3.0 //done in 3.0
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Revimg([Leftover] string imageLink = null)
public async Task Revimg([Leftover] string imageLink = null)
{ {
imageLink = imageLink?.Trim() ?? ""; imageLink = imageLink?.Trim() ?? "";
@@ -603,9 +582,8 @@ public partial class Searches : NadekoModule<SearchesService>
await SendConfirmAsync($"https://images.google.com/searchbyimage?image_url={imageLink}"); await SendConfirmAsync($"https://images.google.com/searchbyimage?image_url={imageLink}");
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Wiki([Leftover] string query = null)
public async Task Wiki([Leftover] string query = null)
{ {
query = query?.Trim(); query = query?.Trim();
@@ -623,9 +601,8 @@ public partial class Searches : NadekoModule<SearchesService>
await ctx.Channel.SendMessageAsync(data.Query.Pages[0].FullUrl); await ctx.Channel.SendMessageAsync(data.Query.Pages[0].FullUrl);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Color(params Color[] colors)
public async Task Color(params Color[] colors)
{ {
if (!colors.Any()) if (!colors.Any())
return; return;
@@ -643,10 +620,9 @@ public partial class Searches : NadekoModule<SearchesService>
await ctx.Channel.SendFileAsync(ms, "colors.png"); await ctx.Channel.SendFileAsync(ms, "colors.png");
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Avatar([Leftover] IGuildUser usr = null) public async partial Task Avatar([Leftover] IGuildUser usr = null)
{ {
if (usr is null) if (usr is null)
usr = (IGuildUser)ctx.User; usr = (IGuildUser)ctx.User;
@@ -668,9 +644,8 @@ public partial class Searches : NadekoModule<SearchesService>
ctx.User.Mention); ctx.User.Mention);
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Wikia(string target, [Leftover] string query)
public async Task Wikia(string target, [Leftover] string query)
{ {
if (string.IsNullOrWhiteSpace(target) || string.IsNullOrWhiteSpace(query)) if (string.IsNullOrWhiteSpace(target) || string.IsNullOrWhiteSpace(query))
{ {
@@ -709,10 +684,9 @@ public partial class Searches : NadekoModule<SearchesService>
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Bible(string book, string chapterAndVerse) public async partial Task Bible(string book, string chapterAndVerse)
{ {
var obj = new BibleVerses(); var obj = new BibleVerses();
try try
@@ -740,9 +714,8 @@ public partial class Searches : NadekoModule<SearchesService>
} }
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Steam([Leftover] string query)
public async Task Steam([Leftover] string query)
{ {
if (string.IsNullOrWhiteSpace(query)) if (string.IsNullOrWhiteSpace(query))
return; return;
@@ -769,7 +742,7 @@ public partial class Searches : NadekoModule<SearchesService>
await ctx.Channel.SendMessageAsync($"https://store.steampowered.com/app/{appId}"); await ctx.Channel.SendMessageAsync($"https://store.steampowered.com/app/{appId}");
} }
public async Task<bool> ValidateQuery(string query) private async Task<bool> ValidateQuery(string query)
{ {
if (!string.IsNullOrWhiteSpace(query)) return true; if (!string.IsNullOrWhiteSpace(query)) return true;

View File

@@ -9,7 +9,7 @@ namespace NadekoBot.Modules.Searches;
public partial class Searches public partial class Searches
{ {
[Group] [Group]
public class StreamNotificationCommands : NadekoSubmodule<StreamNotificationService> public partial class StreamNotificationCommands : NadekoSubmodule<StreamNotificationService>
{ {
private readonly DbService _db; private readonly DbService _db;
@@ -19,11 +19,10 @@ public partial class Searches
// private static readonly Regex picartoRegex = new Regex(@"picarto.tv/(?<name>.+[^/])/?", // private static readonly Regex picartoRegex = new Regex(@"picarto.tv/(?<name>.+[^/])/?",
// RegexOptions.Compiled | RegexOptions.IgnoreCase); // RegexOptions.Compiled | RegexOptions.IgnoreCase);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
public async Task StreamAdd(string link) public async partial Task StreamAdd(string link)
{ {
var data = await _service.FollowStream(ctx.Guild.Id, ctx.Channel.Id, link); var data = await _service.FollowStream(ctx.Guild.Id, ctx.Channel.Id, link);
if (data is null) if (data is null)
@@ -36,12 +35,11 @@ public partial class Searches
await ctx.Channel.EmbedAsync(embed, GetText(strs.stream_tracked)); await ctx.Channel.EmbedAsync(embed, GetText(strs.stream_tracked));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
[Priority(1)] [Priority(1)]
public async Task StreamRemove(int index) public async partial Task StreamRemove(int index)
{ {
if (--index < 0) if (--index < 0)
return; return;
@@ -56,20 +54,18 @@ public partial class Searches
await ReplyConfirmLocalizedAsync(strs.stream_removed(Format.Bold(fs.Username), fs.Type)); await ReplyConfirmLocalizedAsync(strs.stream_removed(Format.Bold(fs.Username), fs.Type));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task StreamsClear() public async partial Task StreamsClear()
{ {
var count = _service.ClearAllStreams(ctx.Guild.Id); var count = _service.ClearAllStreams(ctx.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.streams_cleared); await ReplyConfirmLocalizedAsync(strs.streams_cleared);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task StreamList(int page = 1) public async partial Task StreamList(int page = 1)
{ {
if (page-- < 1) return; if (page-- < 1) return;
@@ -113,11 +109,10 @@ public partial class Searches
12); 12);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
public async Task StreamOffline() public async partial Task StreamOffline()
{ {
var newValue = _service.ToggleStreamOffline(ctx.Guild.Id); var newValue = _service.ToggleStreamOffline(ctx.Guild.Id);
if (newValue) if (newValue)
@@ -126,11 +121,10 @@ public partial class Searches
await ReplyConfirmLocalizedAsync(strs.stream_off_disabled); await ReplyConfirmLocalizedAsync(strs.stream_off_disabled);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
public async Task StreamMessage(int index, [Leftover] string message) public async partial Task StreamMessage(int index, [Leftover] string message)
{ {
if (--index < 0) if (--index < 0)
return; return;
@@ -147,11 +141,10 @@ public partial class Searches
await ReplyConfirmLocalizedAsync(strs.stream_message_set(Format.Bold(fs.Username))); await ReplyConfirmLocalizedAsync(strs.stream_message_set(Format.Bold(fs.Username)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
public async Task StreamMessageAll([Leftover] string message) public async partial Task StreamMessageAll([Leftover] string message)
{ {
var count = _service.SetStreamMessageForAll(ctx.Guild.Id, message); var count = _service.SetStreamMessageForAll(ctx.Guild.Id, message);
@@ -164,10 +157,9 @@ public partial class Searches
await ReplyConfirmLocalizedAsync(strs.stream_message_set_all(count)); await ReplyConfirmLocalizedAsync(strs.stream_message_set_all(count));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task StreamCheck(string url) public async partial Task StreamCheck(string url)
{ {
try try
{ {

View File

@@ -4,7 +4,7 @@ namespace NadekoBot.Modules.Searches;
public partial class Searches public partial class Searches
{ {
[Group] [Group]
public class TranslateCommands : NadekoSubmodule<ITranslateService> public partial class TranslateCommands : NadekoSubmodule<ITranslateService>
{ {
public enum AutoDeleteAutoTranslate public enum AutoDeleteAutoTranslate
{ {
@@ -12,9 +12,8 @@ public partial class Searches
Nodel Nodel
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Translate(string from, string to, [Leftover] string text = null)
public async Task Translate(string from, string to, [Leftover] string text = null)
{ {
try try
{ {
@@ -31,13 +30,12 @@ public partial class Searches
} }
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[BotPerm(ChannelPerm.ManageMessages)] [BotPerm(ChannelPerm.ManageMessages)]
[OwnerOnly] [OwnerOnly]
public async Task AutoTranslate(AutoDeleteAutoTranslate autoDelete = AutoDeleteAutoTranslate.Nodel) public async partial Task AutoTranslate(AutoDeleteAutoTranslate autoDelete = AutoDeleteAutoTranslate.Nodel)
{ {
var toggle = var toggle =
await _service.ToggleAtl(ctx.Guild.Id, ctx.Channel.Id, autoDelete == AutoDeleteAutoTranslate.Del); await _service.ToggleAtl(ctx.Guild.Id, ctx.Channel.Id, autoDelete == AutoDeleteAutoTranslate.Del);
@@ -47,19 +45,17 @@ public partial class Searches
await ReplyConfirmLocalizedAsync(strs.atl_stopped); await ReplyConfirmLocalizedAsync(strs.atl_stopped);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task AutoTransLang() public async partial Task AutoTransLang()
{ {
if (await _service.UnregisterUser(ctx.Channel.Id, ctx.User.Id)) if (await _service.UnregisterUser(ctx.Channel.Id, ctx.User.Id))
await ReplyConfirmLocalizedAsync(strs.atl_removed); await ReplyConfirmLocalizedAsync(strs.atl_removed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task AutoTransLang(string from, string to) public async partial Task AutoTransLang(string from, string to)
{ {
var succ = await _service.RegisterUserAsync(ctx.User.Id, ctx.Channel.Id, from.ToLower(), to.ToLower()); var succ = await _service.RegisterUserAsync(ctx.User.Id, ctx.Channel.Id, from.ToLower(), to.ToLower());
@@ -78,10 +74,9 @@ public partial class Searches
await ReplyConfirmLocalizedAsync(strs.atl_set(from, to)); await ReplyConfirmLocalizedAsync(strs.atl_set(from, to));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Translangs() public async partial Task Translangs()
=> await ctx.Channel.SendTableAsync(_service.GetLanguages(), str => $"{str,-15}"); => await ctx.Channel.SendTableAsync(_service.GetLanguages(), str => $"{str,-15}");
} }
} }

View File

@@ -6,7 +6,7 @@ namespace NadekoBot.Modules.Searches;
public partial class Searches public partial class Searches
{ {
[Group] [Group]
public class XkcdCommands : NadekoSubmodule public partial class XkcdCommands : NadekoSubmodule
{ {
private const string _xkcdUrl = "https://xkcd.com"; private const string _xkcdUrl = "https://xkcd.com";
private readonly IHttpClientFactory _httpFactory; private readonly IHttpClientFactory _httpFactory;
@@ -14,10 +14,9 @@ public partial class Searches
public XkcdCommands(IHttpClientFactory factory) public XkcdCommands(IHttpClientFactory factory)
=> _httpFactory = factory; => _httpFactory = factory;
[NadekoCommand] [Cmd]
[Aliases]
[Priority(0)] [Priority(0)]
public async Task Xkcd(string arg = null) public async partial Task Xkcd(string arg = null)
{ {
if (arg?.ToLowerInvariant().Trim() == "latest") if (arg?.ToLowerInvariant().Trim() == "latest")
{ {
@@ -49,10 +48,9 @@ public partial class Searches
await Xkcd(new NadekoRandom().Next(1, 1750)); await Xkcd(new NadekoRandom().Next(1, 1750));
} }
[NadekoCommand] [Cmd]
[Aliases]
[Priority(1)] [Priority(1)]
public async Task Xkcd(int num) public async partial Task Xkcd(int num)
{ {
if (num < 1) if (num < 1)
return; return;

View File

@@ -4,7 +4,7 @@ namespace NadekoBot.Modules.Searches;
public partial class Searches public partial class Searches
{ {
// [Group] // [Group]
// public class YtTrackCommands : NadekoSubmodule<YtTrackService> // public partial class YtTrackCommands : NadekoSubmodule<YtTrackService>
// { // {
// ; // ;
// [RequireContext(ContextType.Guild)] // [RequireContext(ContextType.Guild)]

View File

@@ -7,11 +7,10 @@ namespace NadekoBot.Modules.Utility;
public partial class Utility public partial class Utility
{ {
[Group] [Group]
public class CalcCommands : NadekoSubmodule public partial class CalcCommands : NadekoSubmodule
{ {
[NadekoCommand] [Cmd]
[Aliases] public async partial Task Calculate([Leftover] string expression)
public async Task Calculate([Leftover] string expression)
{ {
var expr = new Expression(expression, EvaluateOptions.IgnoreCase | EvaluateOptions.NoCache); var expr = new Expression(expression, EvaluateOptions.IgnoreCase | EvaluateOptions.NoCache);
expr.EvaluateParameter += Expr_EvaluateParameter; expr.EvaluateParameter += Expr_EvaluateParameter;
@@ -35,9 +34,8 @@ public partial class Utility
} }
} }
[NadekoCommand] [Cmd]
[Aliases] public async partial Task CalcOps()
public async Task CalcOps()
{ {
var selection = typeof(Math).GetTypeInfo() var selection = typeof(Math).GetTypeInfo()
.GetMethods() .GetMethods()

View File

@@ -9,7 +9,7 @@ namespace NadekoBot.Modules.Utility;
public partial class Utility public partial class Utility
{ {
[Group] [Group]
public class CommandMapCommands : NadekoSubmodule<CommandMapService> public partial class CommandMapCommands : NadekoSubmodule<CommandMapService>
{ {
private readonly DbService _db; private readonly DbService _db;
private readonly DiscordSocketClient _client; private readonly DiscordSocketClient _client;
@@ -20,21 +20,19 @@ public partial class Utility
_client = client; _client = client;
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task AliasesClear() public async partial Task AliasesClear()
{ {
var count = _service.ClearAliases(ctx.Guild.Id); var count = _service.ClearAliases(ctx.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.aliases_cleared(count)); await ReplyConfirmLocalizedAsync(strs.aliases_cleared(count));
} }
[NadekoCommand] [Cmd]
[Aliases]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Alias(string trigger, [Leftover] string mapping = null) public async partial Task Alias(string trigger, [Leftover] string mapping = null)
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;
@@ -101,10 +99,9 @@ public partial class Utility
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task AliasList(int page = 1) public async partial Task AliasList(int page = 1)
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;
page -= 1; page -= 1;

View File

@@ -3,17 +3,16 @@ namespace NadekoBot.Modules.Utility;
public partial class Utility public partial class Utility
{ {
public class ConfigCommands : NadekoSubmodule public partial class ConfigCommands : NadekoSubmodule
{ {
private readonly IEnumerable<IConfigService> _settingServices; private readonly IEnumerable<IConfigService> _settingServices;
public ConfigCommands(IEnumerable<IConfigService> settingServices) public ConfigCommands(IEnumerable<IConfigService> settingServices)
=> _settingServices = settingServices; => _settingServices = settingServices;
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task ConfigReload(string name) public async partial Task ConfigReload(string name)
{ {
var setting = _settingServices.FirstOrDefault(x var setting = _settingServices.FirstOrDefault(x
=> x.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase)); => x.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase));
@@ -34,10 +33,9 @@ public partial class Utility
await ctx.OkAsync(); await ctx.OkAsync();
} }
[NadekoCommand] [Cmd]
[Aliases]
[OwnerOnly] [OwnerOnly]
public async Task Config(string name = null, string prop = null, [Leftover] string value = null) public async partial Task Config(string name = null, string prop = null, [Leftover] string value = null)
{ {
var configNames = _settingServices.Select(x => x.Name); var configNames = _settingServices.Select(x => x.Name);

View File

@@ -6,7 +6,7 @@ namespace NadekoBot.Modules.Utility;
public partial class Utility public partial class Utility
{ {
[Group] [Group]
public class InfoCommands : NadekoSubmodule public partial class InfoCommands : NadekoSubmodule
{ {
private readonly DiscordSocketClient _client; private readonly DiscordSocketClient _client;
private readonly IStatsService _stats; private readonly IStatsService _stats;
@@ -17,10 +17,9 @@ public partial class Utility
_stats = stats; _stats = stats;
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task ServerInfo(string guildName = null) public async partial Task ServerInfo(string guildName = null)
{ {
var channel = (ITextChannel)ctx.Channel; var channel = (ITextChannel)ctx.Channel;
guildName = guildName?.ToUpperInvariant(); guildName = guildName?.ToUpperInvariant();
@@ -65,10 +64,9 @@ public partial class Utility
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task ChannelInfo(ITextChannel channel = null) public async partial Task ChannelInfo(ITextChannel channel = null)
{ {
var ch = channel ?? (ITextChannel)ctx.Channel; var ch = channel ?? (ITextChannel)ctx.Channel;
if (ch is null) if (ch is null)
@@ -85,10 +83,9 @@ public partial class Utility
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task UserInfo(IGuildUser usr = null) public async partial Task UserInfo(IGuildUser usr = null)
{ {
var user = usr ?? ctx.User as IGuildUser; var user = usr ?? ctx.User as IGuildUser;
@@ -111,11 +108,10 @@ public partial class Utility
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[OwnerOnly] [OwnerOnly]
public async Task Activity(int page = 1) public async partial Task Activity(int page = 1)
{ {
const int activityPerPage = 10; const int activityPerPage = 10;
page -= 1; page -= 1;

View File

@@ -6,15 +6,14 @@ namespace NadekoBot.Modules.Utility;
public partial class Utility public partial class Utility
{ {
[Group] [Group]
public class InviteCommands : NadekoSubmodule<InviteService> public partial class InviteCommands : NadekoSubmodule<InviteService>
{ {
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[BotPerm(ChannelPerm.CreateInstantInvite)] [BotPerm(ChannelPerm.CreateInstantInvite)]
[UserPerm(ChannelPerm.CreateInstantInvite)] [UserPerm(ChannelPerm.CreateInstantInvite)]
[NadekoOptions(typeof(InviteService.Options))] [NadekoOptions(typeof(InviteService.Options))]
public async Task InviteCreate(params string[] args) public async partial Task InviteCreate(params string[] args)
{ {
var (opts, success) = OptionsParser.ParseFrom(new InviteService.Options(), args); var (opts, success) = OptionsParser.ParseFrom(new InviteService.Options(), args);
if (!success) if (!success)
@@ -26,12 +25,11 @@ public partial class Utility
await SendConfirmAsync($"{ctx.User.Mention} https://discord.gg/{invite.Code}"); await SendConfirmAsync($"{ctx.User.Mention} https://discord.gg/{invite.Code}");
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[BotPerm(ChannelPerm.ManageChannels)] [BotPerm(ChannelPerm.ManageChannels)]
[UserPerm(ChannelPerm.ManageChannels)] [UserPerm(ChannelPerm.ManageChannels)]
public async Task InviteList(int page = 1, [Leftover] ITextChannel ch = null) public async partial Task InviteList(int page = 1, [Leftover] ITextChannel ch = null)
{ {
if (--page < 0) if (--page < 0)
return; return;
@@ -71,12 +69,11 @@ public partial class Utility
9); 9);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[BotPerm(ChannelPerm.ManageChannels)] [BotPerm(ChannelPerm.ManageChannels)]
[UserPerm(ChannelPerm.ManageChannels)] [UserPerm(ChannelPerm.ManageChannels)]
public async Task InviteDelete(int index) public async partial Task InviteDelete(int index)
{ {
if (--index < 0) if (--index < 0)
return; return;

View File

@@ -10,7 +10,7 @@ namespace NadekoBot.Modules.Utility;
public partial class Utility public partial class Utility
{ {
[Group] [Group]
public class QuoteCommands : NadekoSubmodule public partial class QuoteCommands : NadekoSubmodule
{ {
private const string _prependExport = private const string _prependExport =
@"# Keys are keywords, Each key has a LIST of quotes in the following format: @"# Keys are keywords, Each key has a LIST of quotes in the following format:
@@ -40,18 +40,16 @@ public partial class Utility
_http = http; _http = http;
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(1)] [Priority(1)]
public Task ListQuotes(OrderType order = OrderType.Keyword) public partial Task ListQuotes(OrderType order = OrderType.Keyword)
=> ListQuotes(1, order); => ListQuotes(1, order);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(0)] [Priority(0)]
public async Task ListQuotes(int page = 1, OrderType order = OrderType.Keyword) public async partial Task ListQuotes(int page = 1, OrderType order = OrderType.Keyword)
{ {
page -= 1; page -= 1;
if (page < 0) if (page < 0)
@@ -72,10 +70,9 @@ public partial class Utility
await ReplyErrorLocalizedAsync(strs.quotes_page_none); await ReplyErrorLocalizedAsync(strs.quotes_page_none);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task QuotePrint([Leftover] string keyword) public async partial Task QuotePrint([Leftover] string keyword)
{ {
if (string.IsNullOrWhiteSpace(keyword)) if (string.IsNullOrWhiteSpace(keyword))
return; return;
@@ -104,10 +101,9 @@ public partial class Utility
await ctx.Channel.SendAsync($"`#{quote.Id}` 📣 " + text, true); await ctx.Channel.SendAsync($"`#{quote.Id}` 📣 " + text, true);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task QuoteShow(int id) public async partial Task QuoteShow(int id)
{ {
Quote quote; Quote quote;
await using (var uow = _db.GetDbContext()) await using (var uow = _db.GetDbContext())
@@ -136,10 +132,9 @@ public partial class Utility
.WithFooter( .WithFooter(
GetText(strs.created_by($"{data.AuthorName} ({data.AuthorId})")))); GetText(strs.created_by($"{data.AuthorName} ({data.AuthorId})"))));
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task QuoteSearch(string keyword, [Leftover] string text) public async partial Task QuoteSearch(string keyword, [Leftover] string text)
{ {
if (string.IsNullOrWhiteSpace(keyword) || string.IsNullOrWhiteSpace(text)) if (string.IsNullOrWhiteSpace(keyword) || string.IsNullOrWhiteSpace(text))
return; return;
@@ -161,10 +156,9 @@ public partial class Utility
+ keywordquote.Text.SanitizeAllMentions()); + keywordquote.Text.SanitizeAllMentions());
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task QuoteId(int id) public async partial Task QuoteId(int id)
{ {
if (id < 0) if (id < 0)
return; return;
@@ -194,10 +188,9 @@ public partial class Utility
await ctx.Channel.SendAsync(infoText + text, true); await ctx.Channel.SendAsync(infoText + text, true);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task QuoteAdd(string keyword, [Leftover] string text) public async partial Task QuoteAdd(string keyword, [Leftover] string text)
{ {
if (string.IsNullOrWhiteSpace(keyword) || string.IsNullOrWhiteSpace(text)) if (string.IsNullOrWhiteSpace(keyword) || string.IsNullOrWhiteSpace(text))
return; return;
@@ -221,10 +214,9 @@ public partial class Utility
await ReplyConfirmLocalizedAsync(strs.quote_added_new(Format.Code(q.Id.ToString()))); await ReplyConfirmLocalizedAsync(strs.quote_added_new(Format.Code(q.Id.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task QuoteDelete(int id) public async partial Task QuoteDelete(int id)
{ {
var hasManageMessages = ((IGuildUser)ctx.Message.Author).GuildPermissions.ManageMessages; var hasManageMessages = ((IGuildUser)ctx.Message.Author).GuildPermissions.ManageMessages;
@@ -253,11 +245,10 @@ public partial class Utility
await SendErrorAsync(response); await SendErrorAsync(response);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
public async Task DelAllQuotes([Leftover] string keyword) public async partial Task DelAllQuotes([Leftover] string keyword)
{ {
if (string.IsNullOrWhiteSpace(keyword)) if (string.IsNullOrWhiteSpace(keyword))
return; return;
@@ -274,11 +265,10 @@ public partial class Utility
await ReplyConfirmLocalizedAsync(strs.quotes_deleted(Format.Bold(keyword.SanitizeAllMentions()))); await ReplyConfirmLocalizedAsync(strs.quotes_deleted(Format.Bold(keyword.SanitizeAllMentions())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
public async Task QuotesExport() public async partial Task QuotesExport()
{ {
IEnumerable<Quote> quotes; IEnumerable<Quote> quotes;
await using (var uow = _db.GetDbContext()) await using (var uow = _db.GetDbContext())
@@ -295,15 +285,14 @@ public partial class Utility
await ctx.Channel.SendFileAsync(stream, "quote-export.yml"); await ctx.Channel.SendFileAsync(stream, "quote-export.yml");
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[Ratelimit(300)] [Ratelimit(300)]
#if GLOBAL_NADEKO #if GLOBAL_NADEKO
[OwnerOnly] [OwnerOnly]
#endif #endif
public async Task QuotesImport([Leftover] string input = null) public async partial Task QuotesImport([Leftover] string input = null)
{ {
input = input?.Trim(); input = input?.Trim();
@@ -338,7 +327,7 @@ public partial class Utility
await ctx.OkAsync(); await ctx.OkAsync();
} }
public async Task<bool> ImportCrsAsync(ulong guildId, string input) private async Task<bool> ImportCrsAsync(ulong guildId, string input)
{ {
Dictionary<string, List<ExportedQuote>> data; Dictionary<string, List<ExportedQuote>> data;
try try

View File

@@ -10,7 +10,7 @@ namespace NadekoBot.Modules.Utility;
public partial class Utility public partial class Utility
{ {
[Group] [Group]
public class RemindCommands : NadekoSubmodule<RemindService> public partial class RemindCommands : NadekoSubmodule<RemindService>
{ {
public enum MeOrHere public enum MeOrHere
{ {
@@ -35,10 +35,9 @@ public partial class Utility
_tz = tz; _tz = tz;
} }
[NadekoCommand] [Cmd]
[Aliases]
[Priority(1)] [Priority(1)]
public async Task Remind(MeOrHere meorhere, [Leftover] string remindString) public async partial Task Remind(MeOrHere meorhere, [Leftover] string remindString)
{ {
if (!_service.TryParseRemindMessage(remindString, out var remindData)) if (!_service.TryParseRemindMessage(remindString, out var remindData))
{ {
@@ -54,12 +53,11 @@ public partial class Utility
remindData.What)) await ReplyErrorLocalizedAsync(strs.remind_too_long); remindData.What)) await ReplyErrorLocalizedAsync(strs.remind_too_long);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
[Priority(0)] [Priority(0)]
public async Task Remind(ITextChannel channel, [Leftover] string remindString) public async partial Task Remind(ITextChannel channel, [Leftover] string remindString)
{ {
var perms = ((IGuildUser)ctx.User).GetPermissions(channel); var perms = ((IGuildUser)ctx.User).GetPermissions(channel);
if (!perms.SendMessages || !perms.ViewChannel) if (!perms.SendMessages || !perms.ViewChannel)
@@ -79,18 +77,16 @@ public partial class Utility
await ReplyErrorLocalizedAsync(strs.remind_too_long); await ReplyErrorLocalizedAsync(strs.remind_too_long);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[Priority(0)] [Priority(0)]
public Task RemindList(Server _, int page = 1) public partial Task RemindList(Server _, int page = 1)
=> RemindListInternal(page, true); => RemindListInternal(page, true);
[NadekoCommand] [Cmd]
[Aliases]
[Priority(1)] [Priority(1)]
public Task RemindList(int page = 1) public partial Task RemindList(int page = 1)
=> RemindListInternal(page, false); => RemindListInternal(page, false);
private async Task RemindListInternal(int page, bool isServer) private async Task RemindListInternal(int page, bool isServer)
@@ -135,18 +131,16 @@ public partial class Utility
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.Administrator)] [UserPerm(GuildPerm.Administrator)]
[Priority(0)] [Priority(0)]
public Task RemindDelete(Server _, int index) public partial Task RemindDelete(Server _, int index)
=> RemindDelete(index, true); => RemindDelete(index, true);
[NadekoCommand] [Cmd]
[Aliases]
[Priority(1)] [Priority(1)]
public Task RemindDelete(int index) public partial Task RemindDelete(int index)
=> RemindDelete(index, false); => RemindDelete(index, false);
private async Task RemindDelete(int index, bool isServer) private async Task RemindDelete(int index, bool isServer)

View File

@@ -7,13 +7,12 @@ namespace NadekoBot.Modules.Utility;
public partial class Utility public partial class Utility
{ {
[Group] [Group]
public class RepeatCommands : NadekoSubmodule<RepeaterService> public partial class RepeatCommands : NadekoSubmodule<RepeaterService>
{ {
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
public async Task RepeatInvoke(int index) public async partial Task RepeatInvoke(int index)
{ {
if (--index < 0) if (--index < 0)
return; return;
@@ -22,11 +21,10 @@ public partial class Utility
if (!success) await ReplyErrorLocalizedAsync(strs.repeat_invoke_none); if (!success) await ReplyErrorLocalizedAsync(strs.repeat_invoke_none);
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
public async Task RepeatRemove(int index) public async partial Task RepeatRemove(int index)
{ {
if (--index < 0) if (--index < 0)
return; return;
@@ -45,11 +43,10 @@ public partial class Utility
.WithDescription(description)); .WithDescription(description));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
public async Task RepeatRedundant(int index) public async partial Task RepeatRedundant(int index)
{ {
if (--index < 0) if (--index < 0)
return; return;
@@ -68,36 +65,32 @@ public partial class Utility
await ReplyConfirmLocalizedAsync(strs.repeater_redundant_yes(index + 1)); await ReplyConfirmLocalizedAsync(strs.repeater_redundant_yes(index + 1));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
[Priority(-1)] [Priority(-1)]
public Task Repeat([Leftover] string message) public partial Task Repeat([Leftover] string message)
=> Repeat(null, null, message); => Repeat(null, null, message);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
[Priority(0)] [Priority(0)]
public Task Repeat(StoopidTime interval, [Leftover] string message) public partial Task Repeat(StoopidTime interval, [Leftover] string message)
=> Repeat(null, interval, message); => Repeat(null, interval, message);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
[Priority(1)] [Priority(1)]
public Task Repeat(GuildDateTime dt, [Leftover] string message) public partial Task Repeat(GuildDateTime dt, [Leftover] string message)
=> Repeat(dt, null, message); => Repeat(dt, null, message);
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
[Priority(2)] [Priority(2)]
public async Task Repeat(GuildDateTime? dt, StoopidTime? interval, [Leftover] string message) public async partial Task Repeat(GuildDateTime? dt, StoopidTime? interval, [Leftover] string message)
{ {
var startTimeOfDay = dt?.InputTimeUtc.TimeOfDay; var startTimeOfDay = dt?.InputTimeUtc.TimeOfDay;
// if interval not null, that means user specified it (don't change it) // if interval not null, that means user specified it (don't change it)
@@ -137,11 +130,10 @@ public partial class Utility
.WithDescription(description)); .WithDescription(description));
} }
[NadekoCommand] [Cmd]
[Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)] [UserPerm(GuildPerm.ManageMessages)]
public async Task RepeatList() public async partial Task RepeatList()
{ {
var repeaters = _service.GetRepeaters(ctx.Guild.Id); var repeaters = _service.GetRepeaters(ctx.Guild.Id);
if (repeaters.Count == 0) if (repeaters.Count == 0)

View File

@@ -6,14 +6,13 @@ namespace NadekoBot.Modules.Utility;
public partial class Utility public partial class Utility
{ {
public class StreamRoleCommands : NadekoSubmodule<StreamRoleService> public partial class StreamRoleCommands : NadekoSubmodule<StreamRoleService>
{ {
[NadekoCommand] [Cmd]
[Aliases]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task StreamRole(IRole fromRole, IRole addRole) public async partial Task StreamRole(IRole fromRole, IRole addRole)
{ {
await _service.SetStreamRole(fromRole, addRole); await _service.SetStreamRole(fromRole, addRole);
@@ -21,23 +20,21 @@ public partial class Utility
Format.Bold(addRole.ToString()))); Format.Bold(addRole.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task StreamRole() public async partial Task StreamRole()
{ {
await _service.StopStreamRole(ctx.Guild); await _service.StopStreamRole(ctx.Guild);
await ReplyConfirmLocalizedAsync(strs.stream_role_disabled); await ReplyConfirmLocalizedAsync(strs.stream_role_disabled);
} }
[NadekoCommand] [Cmd]
[Aliases]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task StreamRoleKeyword([Leftover] string keyword = null) public async partial Task StreamRoleKeyword([Leftover] string keyword = null)
{ {
var kw = await _service.SetKeyword(ctx.Guild, keyword); var kw = await _service.SetKeyword(ctx.Guild, keyword);
@@ -47,12 +44,11 @@ public partial class Utility
await ReplyConfirmLocalizedAsync(strs.stream_role_kw_set(Format.Bold(kw))); await ReplyConfirmLocalizedAsync(strs.stream_role_kw_set(Format.Bold(kw)));
} }
[NadekoCommand] [Cmd]
[Aliases]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task StreamRoleBlacklist(AddRemove action, [Leftover] IGuildUser user) public async partial Task StreamRoleBlacklist(AddRemove action, [Leftover] IGuildUser user)
{ {
var success = await _service.ApplyListAction(StreamRoleListType.Blacklist, var success = await _service.ApplyListAction(StreamRoleListType.Blacklist,
ctx.Guild, ctx.Guild,
@@ -71,12 +67,11 @@ public partial class Utility
await ReplyErrorLocalizedAsync(strs.stream_role_bl_rem_fail(Format.Bold(user.ToString()))); await ReplyErrorLocalizedAsync(strs.stream_role_bl_rem_fail(Format.Bold(user.ToString())));
} }
[NadekoCommand] [Cmd]
[Aliases]
[BotPerm(GuildPerm.ManageRoles)] [BotPerm(GuildPerm.ManageRoles)]
[UserPerm(GuildPerm.ManageRoles)] [UserPerm(GuildPerm.ManageRoles)]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task StreamRoleWhitelist(AddRemove action, [Leftover] IGuildUser user) public async partial Task StreamRoleWhitelist(AddRemove action, [Leftover] IGuildUser user)
{ {
var success = await _service.ApplyListAction(StreamRoleListType.Whitelist, var success = await _service.ApplyListAction(StreamRoleListType.Whitelist,
ctx.Guild, ctx.Guild,

View File

@@ -6,11 +6,10 @@ namespace NadekoBot.Modules.Utility;
public partial class Utility public partial class Utility
{ {
[Group] [Group]
public class UnitConverterCommands : NadekoSubmodule<ConverterService> public partial class UnitConverterCommands : NadekoSubmodule<ConverterService>
{ {
[NadekoCommand] [Cmd]
[Aliases] public async partial Task ConvertList()
public async Task ConvertList()
{ {
var units = _service.Units; var units = _service.Units;
@@ -24,10 +23,9 @@ public partial class Utility
await ctx.Channel.EmbedAsync(embed); await ctx.Channel.EmbedAsync(embed);
} }
[NadekoCommand] [Cmd]
[Aliases]
[Priority(0)] [Priority(0)]
public async Task Convert(string origin, string target, decimal value) public async partial Task Convert(string origin, string target, decimal value)
{ {
var originUnit = _service.Units.FirstOrDefault(x var originUnit = _service.Units.FirstOrDefault(x
=> x.Triggers.Select(y => y.ToUpperInvariant()).Contains(origin.ToUpperInvariant())); => x.Triggers.Select(y => y.ToUpperInvariant()).Contains(origin.ToUpperInvariant()));

Some files were not shown because too many files have changed in this diff Show More