fixed /form help crashing the bot
This commit is contained in:
10
cmd_form.go
10
cmd_form.go
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
@@ -77,9 +76,13 @@ var cmd_form Command = Command{
|
|||||||
Interact: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
Interact: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
switch i.ApplicationCommandData().Options[0].Name {
|
switch i.ApplicationCommandData().Options[0].Name {
|
||||||
case "help":
|
case "help":
|
||||||
fileData, _ = os.ReadFile("./form_templates/form_demo.json")
|
fileData, err := formTemplates.ReadFile("form_templates/form_demo.json")
|
||||||
|
if err != nil {
|
||||||
|
logrus.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
fileReader := bytes.NewReader(fileData)
|
fileReader := bytes.NewReader(fileData)
|
||||||
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
err = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||||
Data: &discordgo.InteractionResponseData{
|
Data: &discordgo.InteractionResponseData{
|
||||||
Content: "NOT SUPPORTED YET!(use `/form add` instead)\n\nGet the example file edit it (make sure to have a unique \"form_type\") and submit it via `/form create`.\nOr use the demo button to get an idea of how the example would look like.",
|
Content: "NOT SUPPORTED YET!(use `/form add` instead)\n\nGet the example file edit it (make sure to have a unique \"form_type\") and submit it via `/form create`.\nOr use the demo button to get an idea of how the example would look like.",
|
||||||
@@ -177,6 +180,7 @@ var cmd_form Command = Command{
|
|||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
addFormButton(i.GuildID, i.ChannelID, message.ID, formManageID.String(), formID, options.Options[0].ChannelValue(s).ID, overwriteTitle, acceptChannelID, modsCanComment)
|
addFormButton(i.GuildID, i.ChannelID, message.ID, formManageID.String(), formID, options.Options[0].ChannelValue(s).ID, overwriteTitle, acceptChannelID, modsCanComment)
|
||||||
err = respond(i.Interaction, "Successfully added form button!", true)
|
err = respond(i.Interaction, "Successfully added form button!", true)
|
||||||
|
@@ -51,7 +51,7 @@ func webhook(p []byte) {
|
|||||||
var logJson Log
|
var logJson Log
|
||||||
json.Unmarshal(p, &logJson)
|
json.Unmarshal(p, &logJson)
|
||||||
var color string = "36314"
|
var color string = "36314"
|
||||||
if logJson.Level == "Error" {
|
if logJson.Level == "error" {
|
||||||
color = "16739179"
|
color = "16739179"
|
||||||
}
|
}
|
||||||
m := Message{
|
m := Message{
|
||||||
|
4
tool.go
4
tool.go
@@ -57,11 +57,11 @@ func jsonStringShowModal(interaction *discordgo.Interaction, manageID string, fo
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if overwrite[0] != "" {
|
if overwrite != nil && overwrite[0] != "" {
|
||||||
modal.Title = overwrite[0]
|
modal.Title = overwrite[0]
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
if components != nil {
|
if modal.Title != "" && components != nil {
|
||||||
err = bot.InteractionRespond(interaction, &discordgo.InteractionResponse{
|
err = bot.InteractionRespond(interaction, &discordgo.InteractionResponse{
|
||||||
Type: discordgo.InteractionResponseModal,
|
Type: discordgo.InteractionResponseModal,
|
||||||
Data: &discordgo.InteractionResponseData{
|
Data: &discordgo.InteractionResponseData{
|
||||||
|
Reference in New Issue
Block a user