mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-04 00:34:26 -05:00 
			
		
		
		
	Added .todo show, Renamed ReactionRole* commands to rero*
This commit is contained in:
		@@ -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);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
@@ -304,12 +303,18 @@ public sealed class Help : NadekoModule<HelpService>
 | 
			
		||||
    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<HelpService>
 | 
			
		||||
                var data = await GetHelpString();
 | 
			
		||||
                if (data == default)
 | 
			
		||||
                    return;
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                await Response().Text(data).SendAsync();
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
@@ -536,8 +541,8 @@ public sealed class Help : NadekoModule<HelpService>
 | 
			
		||||
                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
 | 
			
		||||
 
 | 
			
		||||
@@ -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>
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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));
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user