diff --git a/ChaosBot/WebServer/App/CustomCommandApi.cs b/ChaosBot/WebServer/App/CustomCommandApi.cs index 97d351b..cec548e 100644 --- a/ChaosBot/WebServer/App/CustomCommandApi.cs +++ b/ChaosBot/WebServer/App/CustomCommandApi.cs @@ -57,21 +57,22 @@ namespace ChaosBot.WebServer.App } [HttpDelete] - [Route("{guildId}")] - public async Task DeleteCustomCommands([FromRoute]ulong guildId, [FromBody]CustomCommandRequest customCommandRequest) + [Route("{guildId}/{command}")] + public async Task DeleteCustomCommands([FromRoute]ulong guildId, [FromRoute]string command) { if (!CheckPermissions.GetResult(Request, guildId, out IActionResult result)) return result; await using ChaosbotContext dbContext = new ChaosbotContext(); - CustomCommand customCommand = new CustomCommand - { - DiscordGuildId = guildId, - Command = customCommandRequest.Command, - Type = customCommandRequest.Type, - Content = customCommandRequest.Content - }; + IQueryable customCommandQuery = dbContext.CustomCommands; + CustomCommand customCommand = customCommandQuery + .Where(cc => cc.DiscordGuildId == guildId) + .First(cc => cc.Command == command); + + if (customCommand == null) + return NotFound(); + dbContext.CustomCommands.Remove(customCommand); await dbContext.SaveChangesAsync();