- 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

@@ -8,18 +8,17 @@ namespace NadekoBot.Modules.Games;
public partial class Games
{
[Group]
public class AcropobiaCommands : NadekoSubmodule<GamesService>
public partial class AcropobiaCommands : NadekoSubmodule<GamesService>
{
private readonly DiscordSocketClient _client;
public AcropobiaCommands(DiscordSocketClient client)
=> _client = client;
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
[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 channel = (ITextChannel)ctx.Channel;

View File

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

View File

@@ -20,9 +20,8 @@ public partial class Games : NadekoModule<GamesService>
_httpFactory = factory;
}
[NadekoCommand]
[Aliases]
public async Task Choose([Leftover] string list = null)
[Cmd]
public async partial Task Choose([Leftover] string list = null)
{
if (string.IsNullOrWhiteSpace(list))
return;
@@ -33,9 +32,8 @@ public partial class Games : NadekoModule<GamesService>
await SendConfirmAsync("🤔", listArr[rng.Next(0, listArr.Length)]);
}
[NadekoCommand]
[Aliases]
public async Task EightBall([Leftover] string question = null)
[Cmd]
public async partial Task EightBall([Leftover] string question = null)
{
if (string.IsNullOrWhiteSpace(question))
return;
@@ -48,10 +46,9 @@ public partial class Games : NadekoModule<GamesService>
.AddField("🎱 " + GetText(strs._8ball), res));
}
[NadekoCommand]
[Aliases]
[Cmd]
[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 originalStream = await gr.Stream;
@@ -141,9 +138,8 @@ public partial class Games : NadekoModule<GamesService>
return new(_images, _httpFactory, crazy, hot, roll, advice);
}
[NadekoCommand]
[Aliases]
public async Task Linux(string guhnoo, string loonix)
[Cmd]
public async partial Task Linux(string guhnoo, string loonix)
=> 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.

View File

@@ -5,12 +5,11 @@ namespace NadekoBot.Modules.Games;
public partial class Games
{
[Group]
public class HangmanCommands : NadekoSubmodule<IHangmanService>
public partial class HangmanCommands : NadekoSubmodule<IHangmanService>
{
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
public async Task Hangmanlist()
public async partial Task Hangmanlist()
=> await SendConfirmAsync(GetText(strs.hangman_types(Prefix)), _service.GetHangmanTypes().Join('\n'));
private static string Draw(HangmanGame.State state)
@@ -44,10 +43,9 @@ public partial class Games
.WithFooter(state.missedLetters.Join(' '));
}
[NadekoCommand]
[Aliases]
[Cmd]
[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))
{
@@ -60,10 +58,9 @@ public partial class Games
await ctx.Channel.EmbedAsync(eb);
}
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
public async Task HangmanStop()
public async partial Task HangmanStop()
{
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
{
[Group]
public class NunchiCommands : NadekoSubmodule<GamesService>
public partial class NunchiCommands : NadekoSubmodule<GamesService>
{
private readonly DiscordSocketClient _client;
public NunchiCommands(DiscordSocketClient client)
=> _client = client;
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
public async Task Nunchi()
public async partial Task Nunchi()
{
var newNunchi = new NunchiGame(ctx.User.Id, ctx.User.ToString());
NunchiGame nunchi;

View File

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

View File

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

View File

@@ -7,7 +7,7 @@ namespace NadekoBot.Modules.Games;
public partial class Games
{
[Group]
public class TicTacToeCommands : NadekoSubmodule<GamesService>
public partial class TicTacToeCommands : NadekoSubmodule<GamesService>
{
private readonly SemaphoreSlim _sem = new(1, 1);
private readonly DiscordSocketClient _client;
@@ -15,11 +15,10 @@ public partial class Games
public TicTacToeCommands(DiscordSocketClient client)
=> _client = client;
[NadekoCommand]
[Aliases]
[Cmd]
[RequireContext(ContextType.Guild)]
[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 channel = (ITextChannel)ctx.Channel;

View File

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