Fix data type (again)
This commit is contained in:
parent
6ffb501428
commit
89a5ea3b15
@ -16,8 +16,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type sendMessageBody struct {
|
type sendMessageBody struct {
|
||||||
MessageType string `json:"type"`
|
Message struct {
|
||||||
Content string `json:"content"`
|
MessageType string `json:"type"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
} `json:"message"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendMessage(ctx *gin.Context) {
|
func SendMessage(ctx *gin.Context) {
|
||||||
@ -52,7 +54,7 @@ func SendMessage(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(body.Content) == 0 {
|
if len(body.Message.Content) == 0 {
|
||||||
ctx.JSON(400, gin.H{
|
ctx.JSON(400, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": "You must enter a message",
|
"error": "You must enter a message",
|
||||||
@ -96,8 +98,8 @@ func SendMessage(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(body.Content) > 2000 {
|
if len(body.Message.Content) > 2000 {
|
||||||
body.Content = body.Content[0:1999]
|
body.Message.Content = body.Message.Content[0:1999]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preferably send via a webhook
|
// Preferably send via a webhook
|
||||||
@ -126,7 +128,7 @@ func SendMessage(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
webhookData = rest.WebhookBody{
|
webhookData = rest.WebhookBody{
|
||||||
Content: body.Content,
|
Content: body.Message.Content,
|
||||||
Username: guild.Name,
|
Username: guild.Name,
|
||||||
AvatarUrl: guild.IconUrl(),
|
AvatarUrl: guild.IconUrl(),
|
||||||
}
|
}
|
||||||
@ -138,7 +140,7 @@ func SendMessage(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
webhookData = rest.WebhookBody{
|
webhookData = rest.WebhookBody{
|
||||||
Content: body.Content,
|
Content: body.Message.Content,
|
||||||
Username: user.EffectiveName(),
|
Username: user.EffectiveName(),
|
||||||
AvatarUrl: user.AvatarUrl(256),
|
AvatarUrl: user.AvatarUrl(256),
|
||||||
}
|
}
|
||||||
@ -161,7 +163,7 @@ func SendMessage(ctx *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message := body.Content
|
message := body.Message.Content
|
||||||
if !settings.AnonymiseDashboardResponses {
|
if !settings.AnonymiseDashboardResponses {
|
||||||
user, err := botContext.GetUser(context.Background(), userId)
|
user, err := botContext.GetUser(context.Background(), userId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user