mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Added .todo show, Renamed ReactionRole* commands to rero*
This commit is contained in:
@@ -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));
|
||||
|
Reference in New Issue
Block a user