Handle non-existent channel

This commit is contained in:
rxdn 2023-09-10 18:08:36 +01:00
parent 80749b8827
commit dbc512237a

View File

@ -148,16 +148,22 @@ func UpdatePanel(ctx *gin.Context) {
newMessageId, err = messageData.send(&botContext) newMessageId, err = messageData.send(&botContext)
if err != nil { if err != nil {
var unwrapped request.RestError var unwrapped request.RestError
if errors.As(err, &unwrapped) && unwrapped.StatusCode == 403 { if errors.As(err, &unwrapped) {
ctx.JSON(500, utils.ErrorStr("I do not have permission to send messages in the specified channel")) if unwrapped.StatusCode == 403 {
ctx.JSON(403, utils.ErrorStr("I do not have permission to send messages in the specified channel"))
return
} else if unwrapped.StatusCode == 404 {
// Swallow error
// TODO: Make channel_id column nullable, and set to null
} else { } else {
// TODO: Most appropriate error?
ctx.JSON(500, utils.ErrorJson(err)) ctx.JSON(500, utils.ErrorJson(err))
} }
} else {
ctx.JSON(500, utils.ErrorJson(err))
return return
} }
} }
}
// Update welcome message // Update welcome message
var welcomeMessageEmbed *int var welcomeMessageEmbed *int