From 818f71c75ae3d4ca4c5e8b42855f3e7a6ef540c2 Mon Sep 17 00:00:00 2001 From: Daniel-I-Am Date: Tue, 29 Sep 2020 22:47:58 +0200 Subject: [PATCH 1/3] Configure frontend for custom commands --- ChaosBot/wwwroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChaosBot/wwwroot b/ChaosBot/wwwroot index d4c2459..731a916 160000 --- a/ChaosBot/wwwroot +++ b/ChaosBot/wwwroot @@ -1 +1 @@ -Subproject commit d4c245976b38189d588304bfc26b644727846c0e +Subproject commit 731a91679f5786e136f06a52b7a62ad45b9a4cd7 From 7c4d007863b91677b9e76e3d4f08cac47610f898 Mon Sep 17 00:00:00 2001 From: Daniel-I-Am Date: Tue, 29 Sep 2020 22:52:14 +0200 Subject: [PATCH 2/3] Fix problem with ulongs on frontend... js does not handle them... at all --- ChaosBot/WebServer/App/CustomCommandApi.cs | 6 +++-- .../WebServer/Models/CustomCommandResponse.cs | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 ChaosBot/WebServer/Models/CustomCommandResponse.cs diff --git a/ChaosBot/WebServer/App/CustomCommandApi.cs b/ChaosBot/WebServer/App/CustomCommandApi.cs index cec548e..86d5e7d 100644 --- a/ChaosBot/WebServer/App/CustomCommandApi.cs +++ b/ChaosBot/WebServer/App/CustomCommandApi.cs @@ -30,7 +30,9 @@ namespace ChaosBot.WebServer.App .Where(cc => cc.DiscordGuildId == guildId) .ToList(); - return Json(customCommands); + List response = customCommands.Select(e => new CustomCommandResponse(e)).ToList(); + + return Json(response); } [HttpPost] @@ -79,4 +81,4 @@ namespace ChaosBot.WebServer.App return NoContent(); } } -} \ No newline at end of file +} diff --git a/ChaosBot/WebServer/Models/CustomCommandResponse.cs b/ChaosBot/WebServer/Models/CustomCommandResponse.cs new file mode 100644 index 0000000..524b13b --- /dev/null +++ b/ChaosBot/WebServer/Models/CustomCommandResponse.cs @@ -0,0 +1,26 @@ +using System.ComponentModel.DataAnnotations; +using ChaosBot.Models; + +namespace ChaosBot.WebServer.Models +{ + class CustomCommandResponse + { + [Required] + public string DiscordGuildId { get; } + [Required] + [MaxLength(128)] + public string Command { get; } + [Required] + public CustomCommandType Type { get; } + [Required] + public string Content { get; } + + public CustomCommandResponse(CustomCommand command) + { + DiscordGuildId = command.DiscordGuildId.ToString(); + Command = command.Command; + Type = command.Type; + Content = command.Content; + } + } +} From dc73b3e507407626a6d27fcb2d0cdcca7a929fca Mon Sep 17 00:00:00 2001 From: Daniel-I-Am Date: Tue, 29 Sep 2020 22:58:52 +0200 Subject: [PATCH 3/3] Replace guild response ID to string --- ChaosBot/WebServer/App/DiscordController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChaosBot/WebServer/App/DiscordController.cs b/ChaosBot/WebServer/App/DiscordController.cs index 6a2b8a5..0e298e0 100644 --- a/ChaosBot/WebServer/App/DiscordController.cs +++ b/ChaosBot/WebServer/App/DiscordController.cs @@ -103,7 +103,7 @@ namespace ChaosBot.WebServer.App List presentGuilds = DiscordConnect._client.Guilds.Select(g => g.Id).ToList(); List userResponseWithPresence = userResponse - .Select(guild => guild.AddPresence(presentGuilds.Contains(guild.id))) + .Select(guild => guild.AddPresence(presentGuilds.Contains(Convert.ToUInt64(guild.id)))) .ToList(); return Json(userResponseWithPresence); @@ -156,7 +156,7 @@ namespace ChaosBot.WebServer.App public class DiscordGuildResponse { - public ulong id { get; set; } + public string id { get; set; } public string name { get; set; } public string icon { get; set; } public bool owner { get; set; }