- 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

@@ -49,12 +49,11 @@ public partial class Utility : NadekoModule
_httpFactory = httpFactory;
}
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)]
[Priority(1)]
public async Task Say(ITextChannel channel, [Leftover] SmartText message)
public async partial Task Say(ITextChannel channel, [Leftover] SmartText message)
{
var rep = new ReplacementBuilder()
.WithDefault(ctx.User, channel, (SocketGuild)ctx.Guild, (DiscordSocketClient)ctx.Client)
@@ -65,18 +64,16 @@ public partial class Utility : NadekoModule
await channel.SendAsync(message, !((IGuildUser)ctx.User).GuildPermissions.MentionEveryone);
}
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)]
[Priority(0)]
public Task Say([Leftover] SmartText message)
public partial Task Say([Leftover] SmartText message)
=> Say((ITextChannel)ctx.Channel, message);
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
public async Task WhosPlaying([Leftover] string game)
public async partial Task WhosPlaying([Leftover] string game)
{
game = game?.Trim().ToUpperInvariant();
if (string.IsNullOrWhiteSpace(game))
@@ -108,11 +105,10 @@ public partial class Utility : NadekoModule
+ "\n```");
}
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
[Priority(0)]
public async Task InRole(int page, [Leftover] IRole role = null)
public async partial Task InRole(int page, [Leftover] IRole role = null)
{
if (--page < 0)
return;
@@ -147,17 +143,15 @@ public partial class Utility : NadekoModule
20);
}
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
[Priority(1)]
public Task InRole([Leftover] IRole role = null)
public partial Task InRole([Leftover] IRole role = null)
=> InRole(1, role);
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
public async Task CheckPerms(MeOrBot who = MeOrBot.Me)
public async partial Task CheckPerms(MeOrBot who = MeOrBot.Me)
{
var builder = new StringBuilder();
var user = who == MeOrBot.Me ? (IGuildUser)ctx.User : ((SocketGuild)ctx.Guild).CurrentUser;
@@ -167,10 +161,9 @@ public partial class Utility : NadekoModule
await SendConfirmAsync(builder.ToString());
}
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
public async Task UserId([Leftover] IGuildUser target = null)
public async partial Task UserId([Leftover] IGuildUser target = null)
{
var usr = target ?? ctx.User;
await ReplyConfirmLocalizedAsync(strs.userid("🆔",
@@ -178,29 +171,25 @@ public partial class Utility : NadekoModule
Format.Code(usr.Id.ToString())));
}
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
public async Task RoleId([Leftover] IRole role)
public async partial Task RoleId([Leftover] IRole role)
=> await ReplyConfirmLocalizedAsync(strs.roleid("🆔",
Format.Bold(role.ToString()),
Format.Code(role.Id.ToString())));
[NadekoCommand]
[Aliases]
public async Task ChannelId()
[Cmd]
public async partial Task ChannelId()
=> await ReplyConfirmLocalizedAsync(strs.channelid("🆔", Format.Code(ctx.Channel.Id.ToString())));
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
public async Task ServerId()
public async partial Task ServerId()
=> await ReplyConfirmLocalizedAsync(strs.serverid("🆔", Format.Code(ctx.Guild.Id.ToString())));
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
public async Task Roles(IGuildUser target, int page = 1)
public async partial Task Roles(IGuildUser target, int page = 1)
{
var guild = ctx.Guild;
@@ -238,16 +227,14 @@ public partial class Utility : NadekoModule
}
}
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
public Task Roles(int page = 1)
public partial Task Roles(int page = 1)
=> Roles(null, page);
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
public async Task ChannelTopic([Leftover] ITextChannel channel = null)
public async partial Task ChannelTopic([Leftover] ITextChannel channel = null)
{
if (channel is null)
channel = (ITextChannel)ctx.Channel;
@@ -259,9 +246,8 @@ public partial class Utility : NadekoModule
await SendConfirmAsync(GetText(strs.channel_topic), topic);
}
[NadekoCommand]
[Aliases]
public async Task Stats()
[Cmd]
public async partial Task Stats()
{
var ownerIds = string.Join("\n", _creds.OwnerIds);
if (string.IsNullOrWhiteSpace(ownerIds))
@@ -293,9 +279,8 @@ public partial class Utility : NadekoModule
true));
}
[NadekoCommand]
[Aliases]
public async Task
[Cmd]
public async partial Task
Showemojis([Leftover] string _) // need to have the parameter so that the message.tags gets populated
{
var tags = ctx.Message.Tags.Where(t => t.Type == TagType.Emoji).Select(t => (Emote)t.Value);
@@ -308,31 +293,28 @@ public partial class Utility : NadekoModule
await ctx.Channel.SendMessageAsync(result.TrimTo(2000));
}
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
[BotPerm(GuildPerm.ManageEmojisAndStickers)]
[UserPerm(GuildPerm.ManageEmojisAndStickers)]
[Priority(2)]
public Task EmojiAdd(string name, Emote emote)
public partial Task EmojiAdd(string name, Emote emote)
=> EmojiAdd(name, emote.Url);
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
[BotPerm(GuildPerm.ManageEmojisAndStickers)]
[UserPerm(GuildPerm.ManageEmojisAndStickers)]
[Priority(1)]
public Task EmojiAdd(Emote emote)
public partial Task EmojiAdd(Emote emote)
=> EmojiAdd(emote.Name, emote.Url);
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
[BotPerm(GuildPerm.ManageEmojisAndStickers)]
[UserPerm(GuildPerm.ManageEmojisAndStickers)]
[Priority(0)]
public async Task EmojiAdd(string name, string url = null)
public async partial Task EmojiAdd(string name, string url = null)
{
name = name.Trim(':');
@@ -366,10 +348,9 @@ public partial class Utility : NadekoModule
await ConfirmLocalizedAsync(strs.emoji_added(em.ToString()));
}
[NadekoCommand]
[Aliases]
[Cmd]
[OwnerOnly]
public async Task ListServers(int page = 1)
public async partial Task ListServers(int page = 1)
{
page -= 1;
@@ -391,16 +372,14 @@ public partial class Utility : NadekoModule
await ctx.Channel.EmbedAsync(embed);
}
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
public Task ShowEmbed(ulong messageId)
public partial Task ShowEmbed(ulong messageId)
=> ShowEmbed((ITextChannel)ctx.Channel, messageId);
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
public async Task ShowEmbed(ITextChannel ch, ulong messageId)
public async partial Task ShowEmbed(ITextChannel ch, ulong messageId)
{
var user = (IGuildUser)ctx.User;
var perms = user.GetPermissions(ch);
@@ -428,11 +407,10 @@ public partial class Utility : NadekoModule
await SendConfirmAsync(Format.Sanitize(json).Replace("](", "]\\("));
}
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
[OwnerOnly]
public async Task SaveChat(int cnt)
public async partial Task SaveChat(int cnt)
{
var msgs = new List<IMessage>(cnt);
await ctx.Channel.GetMessagesAsync(cnt).ForEachAsync(dled => msgs.AddRange(dled));
@@ -469,12 +447,11 @@ public partial class Utility : NadekoModule
await ctx.User.SendFileAsync(stream, title, title);
}
[NadekoCommand]
[Aliases]
[Cmd]
#if GLOBAL_NADEKO
[Ratelimit(30)]
#endif
public async Task Ping()
public async partial Task Ping()
{
await sem.WaitAsync(5000);
try
@@ -511,7 +488,7 @@ public partial class Utility : NadekoModule
//
// [NadekoCommand, Usage, Description, Aliases]
// [RequireContext(ContextType.Guild)]
// public async Task InviteLb(int page = 1)
// public async partial Task InviteLb(int page = 1)
// {
// if (--page < 0)
// return;