Initial split of the modules
This commit is contained in:
13
NadekoBot.Core/Common/Attributes/Aliases.cs
Normal file
13
NadekoBot.Core/Common/Attributes/Aliases.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Services.Impl;
|
||||
namespace NadekoBot.Common.Attributes
|
||||
{
|
||||
public class Aliases : AliasAttribute
|
||||
{
|
||||
public Aliases([CallerMemberName] string memberName = "") : base(Localization.LoadCommand(memberName.ToLowerInvariant()).Cmd.Split(' ').Skip(1).ToArray())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
14
NadekoBot.Core/Common/Attributes/Description.cs
Normal file
14
NadekoBot.Core/Common/Attributes/Description.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Services.Impl;
|
||||
|
||||
namespace NadekoBot.Common.Attributes
|
||||
{
|
||||
public class Description : SummaryAttribute
|
||||
{
|
||||
public Description([CallerMemberName] string memberName="") : base(Localization.LoadCommand(memberName.ToLowerInvariant()).Desc)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
14
NadekoBot.Core/Common/Attributes/NadekoCommand.cs
Normal file
14
NadekoBot.Core/Common/Attributes/NadekoCommand.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Services.Impl;
|
||||
|
||||
namespace NadekoBot.Common.Attributes
|
||||
{
|
||||
public class NadekoCommand : CommandAttribute
|
||||
{
|
||||
public NadekoCommand([CallerMemberName] string memberName="") : base(Localization.LoadCommand(memberName.ToLowerInvariant()).Cmd.Split(' ')[0])
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
14
NadekoBot.Core/Common/Attributes/NadekoModuleAttribute.cs
Normal file
14
NadekoBot.Core/Common/Attributes/NadekoModuleAttribute.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using Discord.Commands;
|
||||
|
||||
namespace NadekoBot.Common.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
sealed class NadekoModuleAttribute : GroupAttribute
|
||||
{
|
||||
public NadekoModuleAttribute(string moduleName) : base(moduleName)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17
NadekoBot.Core/Common/Attributes/OwnerOnlyAttribute.cs
Normal file
17
NadekoBot.Core/Common/Attributes/OwnerOnlyAttribute.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Services;
|
||||
|
||||
namespace NadekoBot.Common.Attributes
|
||||
{
|
||||
public class OwnerOnlyAttribute : PreconditionAttribute
|
||||
{
|
||||
public override Task<PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo executingCommand, IServiceProvider services)
|
||||
{
|
||||
var creds = (IBotCredentials)services.GetService(typeof(IBotCredentials));
|
||||
|
||||
return Task.FromResult((creds.IsOwner(context.User) || context.Client.CurrentUser.Id == context.User.Id ? PreconditionResult.FromSuccess() : PreconditionResult.FromError("Not owner")));
|
||||
}
|
||||
}
|
||||
}
|
24
NadekoBot.Core/Common/Attributes/Usage.cs
Normal file
24
NadekoBot.Core/Common/Attributes/Usage.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Services.Impl;
|
||||
using System.Linq;
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot.Common.Attributes
|
||||
{
|
||||
public class Usage : RemarksAttribute
|
||||
{
|
||||
public Usage([CallerMemberName] string memberName="") : base(Usage.GetUsage(memberName))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static string GetUsage(string memberName)
|
||||
{
|
||||
var usage = Localization.LoadCommand(memberName.ToLowerInvariant()).Usage;
|
||||
return string.Join(" or ", usage
|
||||
.Select(x => Format.Code(x)));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user