Added .todo show, Renamed ReactionRole* commands to rero*

This commit is contained in:
Kwoth
2024-05-02 23:23:26 +00:00
parent 3ef05f8aa7
commit 48e51784da
10 changed files with 83 additions and 34 deletions

View File

@@ -22,6 +22,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
- `.todo done <id>` - completes a todo (marks it with a checkmark)
- `.todo list` - lists all todos
- `.todo edit <id> <new message>` - edits a todo item message
- `.todo show <id>` - Shows the text of the specified todo item
- In addition to that, there are also Todo archive commands
- `.todo archive add <name>` - 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 <module name>` looks better / simpler
- Cleanup: Removed a lot of obsolete aliases.
- `.cmds <module name>`, `.cmds <group name` and `.mdls` looks better / cleaner / simpler
- The bot will now send a discord Reply to every command
- A lot of code cleanup (still a lot to be done) and Quality of Life improvements
@@ -51,10 +51,11 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
### Removed
- `.poll` commands removed, discord added polls.
- `.poll` commands removed as discord added polls
- `.scpl` and other music soundcloud commands have been removed as soundcloud isn't issuing new api tokens for years now
- Removed a lot of useless and nsfw commands
- Removed log voice presence TTS
- Cleanup: Removed a lot of obsolete aliases from aliases.yml
## [4.3.22] - 23.04.2023

View File

@@ -17,7 +17,7 @@ public partial class Administration
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)]
public async Task ReactionRoleAdd(
public async Task ReRoAdd(
ulong messageId,
string emoteStr,
IRole role,
@@ -68,7 +68,7 @@ public partial class Administration
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)]
public async Task ReactionRolesList(int page = 1)
public async Task ReRoList(int page = 1)
{
if (--page < 0)
return;
@@ -124,7 +124,7 @@ public partial class Administration
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)]
public async Task ReactionRolesRemove(ulong messageId)
public async Task ReRoRemove(ulong messageId)
{
var succ = await _rero.RemoveReactionRoles(ctx.Guild.Id, messageId);
if (succ)
@@ -137,7 +137,7 @@ public partial class Administration
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)]
public async Task ReactionRolesDeleteAll()
public async Task ReRoDeleteAll()
{
await _rero.RemoveAllReactionRoles(ctx.Guild.Id);
await ctx.OkAsync();
@@ -148,7 +148,7 @@ public partial class Administration
[UserPerm(GuildPerm.ManageRoles)]
[BotPerm(GuildPerm.ManageRoles)]
[Ratelimit(60)]
public async Task ReactionRolesTransfer(ulong fromMessageId, ulong toMessageId)
public async Task ReRoTransfer(ulong fromMessageId, ulong toMessageId)
{
var msg = await ctx.Channel.GetMessageAsync(toMessageId);

View File

@@ -283,14 +283,13 @@ public sealed class Help : NadekoModule<HelpService>
//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);
@@ -309,7 +308,13 @@ public sealed class Help : NadekoModule<HelpService>
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();

View File

@@ -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<TodoService>
{

View File

@@ -179,4 +179,14 @@ public sealed class TodoService
return count > 0;
}
public async Task<TodoModel?> GetTodoAsync(ulong userId, int todoId)
{
await using var ctx = _db.GetDbContext();
return await ctx
.GetTable<TodoModel>()
.Where(x => x.UserId == userId && x.Id == todoId)
.FirstOrDefaultAsyncLinqToDB();
}
}

View File

@@ -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));

View File

@@ -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<string>();
public static string GetCommandNameFor(string methodName)

View File

@@ -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);

View File

@@ -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

View File

@@ -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: