Start working on custom commands frontend #minor

This commit is contained in:
Daniel_I_Am 2020-09-29 22:59:44 +02:00
commit d268c33624
No known key found for this signature in database
GPG Key ID: 80C428FCC9743E84
4 changed files with 33 additions and 5 deletions

View File

@ -30,7 +30,9 @@ namespace ChaosBot.WebServer.App
.Where(cc => cc.DiscordGuildId == guildId) .Where(cc => cc.DiscordGuildId == guildId)
.ToList(); .ToList();
return Json(customCommands); List<CustomCommandResponse> response = customCommands.Select(e => new CustomCommandResponse(e)).ToList();
return Json(response);
} }
[HttpPost] [HttpPost]
@ -79,4 +81,4 @@ namespace ChaosBot.WebServer.App
return NoContent(); return NoContent();
} }
} }
} }

View File

@ -103,7 +103,7 @@ namespace ChaosBot.WebServer.App
List<ulong> presentGuilds = DiscordConnect._client.Guilds.Select(g => g.Id).ToList(); List<ulong> presentGuilds = DiscordConnect._client.Guilds.Select(g => g.Id).ToList();
List<DiscordGuildResponseWithPresence> userResponseWithPresence = List<DiscordGuildResponseWithPresence> userResponseWithPresence =
userResponse userResponse
.Select(guild => guild.AddPresence(presentGuilds.Contains(guild.id))) .Select(guild => guild.AddPresence(presentGuilds.Contains(Convert.ToUInt64(guild.id))))
.ToList(); .ToList();
return Json(userResponseWithPresence); return Json(userResponseWithPresence);
@ -156,7 +156,7 @@ namespace ChaosBot.WebServer.App
public class DiscordGuildResponse public class DiscordGuildResponse
{ {
public ulong id { get; set; } public string id { get; set; }
public string name { get; set; } public string name { get; set; }
public string icon { get; set; } public string icon { get; set; }
public bool owner { get; set; } public bool owner { get; set; }

View File

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

@ -1 +1 @@
Subproject commit d4c245976b38189d588304bfc26b644727846c0e Subproject commit 731a91679f5786e136f06a52b7a62ad45b9a4cd7