diff --git a/CHANGELOG.md b/CHANGELOG.md index fae904405..fa3907fa4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog. - `.todo done ` - completes a todo (marks it with a checkmark) - `.todo list` - lists all todos - `.todo edit ` - edits a todo item message + - `.todo show ` - Shows the text of the specified todo item - In addition to that, there are also Todo archive commands - `.todo archive add ` - adds all current todos (completed and not completed) to the archived list, your current todo list will become cleared - `.todo archive list` - lists all your archived todo lists @@ -38,8 +39,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog. - Users who have manage messages perm in the channel will now be excluded from link and invite filtering (`.sfi` and `.sfl`) - You can now target a different channel with .repeat, for example `.repeat #some-other 1h Hello every hour` -- `.cmds ` looks better / simpler -- Cleanup: Removed a lot of obsolete aliases. +- `.cmds `, `.cmds //if cross is specified, and the command doesn't satisfy the requirements, cross it out if (opts.View == CommandsOptions.ViewType.Cross) { - return - $"{(succ.Contains(x) ? "✅" : "❌")} {prefix + x.Aliases[0]}"; + return $"{(succ.Contains(x) ? "✅" : "❌")} {prefix + x.Aliases[0]}"; } if (x.Aliases.Count == 1) return prefix + x.Aliases[0]; - return prefix + x.Aliases[0] + " / " + prefix + x.Aliases[1]; + return prefix + x.Aliases[0] + " | " + prefix + x.Aliases[1]; }); embed.AddField(g.ElementAt(i).Key, "" + string.Join("\n", transformed) + "", true); @@ -304,12 +303,18 @@ public sealed class Help : NadekoModule private async Task Group(ModuleInfo group) { var eb = _sender.CreateEmbed() - .WithTitle(GetText(strs.cmd_group_commands(group.Name))) - .WithOkColor(); + .WithTitle(GetText(strs.cmd_group_commands(group.Name))) + .WithOkColor(); foreach (var cmd in group.Commands.DistinctBy(x => x.Aliases[0])) { - eb.AddField(prefix + cmd.Aliases.First(), cmd.RealSummary(_strings, _medusae, Culture, prefix)); + string cmdName; + if (cmd.Aliases.Count > 1) + cmdName = Format.Code(prefix +cmd.Aliases[0]) + " | " + Format.Code(prefix + cmd.Aliases[1]); + else + cmdName = Format.Code(prefix + cmd.Aliases.First()); + + eb.AddField(cmdName, cmd.RealSummary(_strings, _medusae, Culture, prefix)); } await Response().Embed(eb).SendAsync(); @@ -358,7 +363,7 @@ public sealed class Help : NadekoModule var data = await GetHelpString(); if (data == default) return; - + await Response().Text(data).SendAsync(); try { @@ -536,8 +541,8 @@ public sealed class Help : NadekoModule SelfhostAction)); var eb = _sender.CreateEmbed() - .WithOkColor() - .WithTitle("Thank you for considering to donate to the NadekoBot project!"); + .WithOkColor() + .WithTitle("Thank you for considering to donate to the NadekoBot project!"); eb .WithDescription("NadekoBot relies on donations to keep the servers, services and APIs running.\n" @@ -581,7 +586,7 @@ Nadeko will DM you the welcome instructions, and you may start using the patron- .Embed(eb) .Interaction(selfhostInter) .SendAsync(); - + _ = ctx.OkAsync(); } catch diff --git a/src/NadekoBot/Modules/Utility/Todo/TodoCommands.cs b/src/NadekoBot/Modules/Utility/Todo/TodoCommands.cs index 008a4f2ad..62317ac8f 100644 --- a/src/NadekoBot/Modules/Utility/Todo/TodoCommands.cs +++ b/src/NadekoBot/Modules/Utility/Todo/TodoCommands.cs @@ -66,6 +66,22 @@ public partial class Utility .SendAsync(); } + [Cmd] + public async Task TodoShow(kwum todoId) + { + var todo = await _service.GetTodoAsync(ctx.User.Id, todoId); + + if (todo is null) + { + await Response().Error(strs.todo_not_found).SendAsync(); + return; + } + + await Response() + .Confirm($"`{new kwum(todo.Id)}` {todo.Todo}") + .SendAsync(); + } + [Cmd] public async Task TodoComplete(kwum todoId) @@ -105,7 +121,7 @@ public partial class Utility var sb = new StringBuilder(); foreach (var todo in todos) { - sb.AppendLine($"{(todo.IsDone ? "✔" : "□")} {Format.Code(new kwum(todo.Id).ToString())} {todo.Todo}"); + sb.AppendLine(InternalItemShow(todo)); sb.AppendLine("---"); } @@ -113,6 +129,9 @@ public partial class Utility eb.WithDescription(sb.ToString()); } + private static string InternalItemShow(TodoModel todo) + => $"{(todo.IsDone ? "✔" : "□")} {Format.Code(new kwum(todo.Id).ToString())} {todo.Todo}"; + [Group("archive")] public partial class ArchiveCommands : NadekoModule { diff --git a/src/NadekoBot/Modules/Utility/Todo/TodoService.cs b/src/NadekoBot/Modules/Utility/Todo/TodoService.cs index cfedf42b8..d2a99d065 100644 --- a/src/NadekoBot/Modules/Utility/Todo/TodoService.cs +++ b/src/NadekoBot/Modules/Utility/Todo/TodoService.cs @@ -179,4 +179,14 @@ public sealed class TodoService return count > 0; } + + public async Task GetTodoAsync(ulong userId, int todoId) + { + await using var ctx = _db.GetDbContext(); + + return await ctx + .GetTable() + .Where(x => x.UserId == userId && x.Id == todoId) + .FirstOrDefaultAsyncLinqToDB(); + } } \ No newline at end of file diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index df12bb63b..e89ccb8cc 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -664,11 +664,17 @@ public partial class Utility : NadekoModule .WithReferences(this.GetType().Assembly) .WithImports( "System", + "System.Collections.Generic", + "System.IO", "System.Linq", + "System.Net.Http", + "System.Threading", + "System.Threading.Tasks", "NadekoBot", "NadekoBot.Extensions", "Microsoft.Extensions.DependencyInjection", "NadekoBot.Common", + "NadekoBot.Modules", "System.Text", "System.Text.Json"), globalsType: typeof(EvalGlobals)); diff --git a/src/NadekoBot/_common/CommandNameLoadHelper.cs b/src/NadekoBot/_common/CommandNameLoadHelper.cs index d5f023cf8..d115fd331 100644 --- a/src/NadekoBot/_common/CommandNameLoadHelper.cs +++ b/src/NadekoBot/_common/CommandNameLoadHelper.cs @@ -17,7 +17,7 @@ public static class CommandNameLoadHelper public static string[] GetAliasesFor(string methodName) => _lazyCommandAliases.Value.TryGetValue(methodName.ToLowerInvariant(), out var aliases) && aliases.Length > 1 - ? aliases.Skip(1).ToArray() + ? aliases.ToArray() : Array.Empty(); public static string GetCommandNameFor(string methodName) diff --git a/src/NadekoBot/_common/Services/Impl/CommandsUtilityService.cs b/src/NadekoBot/_common/Services/Impl/CommandsUtilityService.cs index 42de90f41..bf002fd3c 100644 --- a/src/NadekoBot/_common/Services/Impl/CommandsUtilityService.cs +++ b/src/NadekoBot/_common/Services/Impl/CommandsUtilityService.cs @@ -35,7 +35,7 @@ public sealed class CommandsUtilityService : ICommandsUtilityService, INService var str = $"**`{prefix + com.Aliases.First()}`**"; var alias = com.Aliases.Skip(1).FirstOrDefault(); if (alias is not null) - str += $" **/ `{prefix + alias}`**"; + str += $" **| `{prefix + alias}`**"; var culture = _loc.GetCultureInfo(guild); diff --git a/src/NadekoBot/data/aliases.yml b/src/NadekoBot/data/aliases.yml index 2841e319d..2b1306b42 100644 --- a/src/NadekoBot/data/aliases.yml +++ b/src/NadekoBot/data/aliases.yml @@ -1160,19 +1160,19 @@ pathofexilecurrency: - poec rollduel: - rollduel -reactionroleadd: - - reactionroleadd +reroadd: + - reroadd - reroa -reactionroleslist: - - reactionroleslist +rerolist: + - rerolist - reroli -reactionrolesremove: - - reactionrolesremove +reroremove: + - reroremove - rerorm -reactionrolesdeleteall: +rerodeleteall: - rerodeleteall - rerodela -reactionrolestransfer: +rerotransfer: - rerotransfer - rerot blackjack: @@ -1387,5 +1387,9 @@ todoarchivedelete: todoedit: - edit - change +todoshow: + - show + - sh + - see stickyroles: - stickyroles diff --git a/src/NadekoBot/data/strings/commands/commands.en-US.yml b/src/NadekoBot/data/strings/commands/commands.en-US.yml index 3e7d8d9e0..bc12fa549 100644 --- a/src/NadekoBot/data/strings/commands/commands.en-US.yml +++ b/src/NadekoBot/data/strings/commands/commands.en-US.yml @@ -2067,7 +2067,7 @@ rollduel: args: - "50 @Someone" - "@Challenger" -reactionroleadd: +reroadd: desc: |- Specify a message id, emote and a role name to have the bot assign the specified role to the user who reacts to the specified message (in this channel) with the specified emoji. You can optionally specify an exclusivity group. Default is group 0 which is non-exclusive. Other groups are exclusive. Exclusive groups will let the user only have one of the roles specified in that group. @@ -2078,19 +2078,19 @@ reactionroleadd: - 971276352684691466 😢 emo 1 - 971276352684691466 🤔 philosopher 5 20 - 971276352684691466 👨 normie 5 20 -reactionroleslist: +rerolist: desc: "Lists all ReactionRole messages on this server with their message ids. Clicking/Tapping message ids will send you to that message." args: - "" -reactionrolesremove: +reroremove: desc: "Remove all reaction roles from message specified by the id" args: - "971276352684691466" -reactionrolesdeleteall: +rerodeleteall: desc: "Deletes all reaction roles on the server. This action is irreversible." args: - "" -reactionrolestransfer: +rerotransfer: desc: "Transfers reaction roles from one message to another by specifying their ids. If the target message has reaction roles specified already, the reaction roles will be MERGED, not overwritten." args: - "971276352684691466 971427748448964628" @@ -2371,6 +2371,10 @@ todoarchiveshow: desc: "Shows the archived todo list with the specified ID." args: - "3c" +todoshow: + desc: "Shows the text of the todo with the specified ID." + args: + - "4a" todoarchivedelete: desc: "Deletes the archived todo list with the specified ID." args: