diff --git a/cmd_form.go b/cmd_form.go index e7d98c5..a1c0608 100644 --- a/cmd_form.go +++ b/cmd_form.go @@ -2,7 +2,7 @@ package main import ( "bytes" - "fmt" + "log" "os" "strings" @@ -28,24 +28,12 @@ var cmd_form Command = Command{ Name: "custom", Description: "Create a new custom form right inside Discord", Options: []*discordgo.ApplicationCommandOption{ - { - Type: discordgo.ApplicationCommandOptionString, - Name: "title", - Description: "The title inside the form window", - Required: true, - }, { Type: discordgo.ApplicationCommandOptionAttachment, Name: "json", Description: "Your edited form file", Required: true, }, - { - Type: discordgo.ApplicationCommandOptionChannel, - Name: "results_channel", - Description: "The channel where the form results should be posted", - Required: true, - }, }, }, { @@ -201,8 +189,11 @@ var cmd_form Command = Command{ var result FormResult = getFormResultValues(form_manage_id) var fields []*discordgo.MessageEmbedField var modal ModalJson = getModalByFormID(getFormType(form_manage_id)) + var overwrite_title string = getFormOverwriteTitle(form_manage_id) + if overwrite_title != "" { + modal.Title = overwrite_title + } for index, component := range i.ModalSubmitData().Components { - fmt.Print(component.(*discordgo.ActionsRow).Components[0].(*discordgo.TextInput)) var input *discordgo.TextInput = component.(*discordgo.ActionsRow).Components[0].(*discordgo.TextInput) fields = append(fields, &discordgo.MessageEmbedField{ Name: modal.Form[index].Label, @@ -211,12 +202,27 @@ var cmd_form Command = Command{ }) } if result.AcceptChannelID == "" { - s.ChannelMessageSendComplex(result.ResultChannelID, &discordgo.MessageSend{ + channel, _ := s.Channel(i.ChannelID) + _, err := s.ChannelMessageSendComplex(result.ResultChannelID, &discordgo.MessageSend{ Embed: &discordgo.MessageEmbed{ - Fields: fields, + Author: &discordgo.MessageEmbedAuthor{ + Name: i.Member.User.Username, + IconURL: i.Member.AvatarURL("256"), + }, + Title: "\"" + modal.Title + "\"", + Color: hexToDecimal(color["primary"]), + Description: "This is the submitted result", + Fields: fields, + Footer: &discordgo.MessageEmbedFooter{ + Text: "From #" + channel.Name, + }, }, }) - respond(i.Interaction, "Submited!", true) + if err != nil { + log.Println(err) + } else { + respond(i.Interaction, "Submited!", true) + } } else { respond(i.Interaction, "The form data would be send to a specified channel. 🤲", true) } diff --git a/form_templates/form_demo.json b/form_templates/form_demo.json index ef6a138..8fcd0a5 100644 --- a/form_templates/form_demo.json +++ b/form_templates/form_demo.json @@ -18,7 +18,7 @@ "value": "We already have some input here", "required": false, "min_length": 0, - "max_length": 2000 + "max_length": 1024 } ] } diff --git a/form_templates/template_general.json b/form_templates/template_general.json index 624aae4..dc1064d 100644 --- a/form_templates/template_general.json +++ b/form_templates/template_general.json @@ -12,7 +12,7 @@ "label": "Text", "is_paragraph": true, "required": true, - "max_length": 2000 + "max_length": 1024 } ] } diff --git a/form_templates/template_ticket.json b/form_templates/template_ticket.json index 56e83c9..439a866 100644 --- a/form_templates/template_ticket.json +++ b/form_templates/template_ticket.json @@ -14,7 +14,7 @@ "is_paragraph": true, "placeholder": "Fill in for what you need help or have issues with and a moderator will reply.", "required": true, - "max_length": 2000 + "max_length": 1024 } ] } diff --git a/form_templates/template_url.json b/form_templates/template_url.json index f572fc9..923dec7 100644 --- a/form_templates/template_url.json +++ b/form_templates/template_url.json @@ -5,7 +5,7 @@ { "label": "URL", "is_paragraph": false, - "placeholder": "https://example.com", + "placeholder": "https://", "value": "", "required": true, "min_length": 0, diff --git a/manage_data.go b/manage_data.go index faff3f3..e4942ce 100644 --- a/manage_data.go +++ b/manage_data.go @@ -278,13 +278,6 @@ func getFormOverwriteTitle(formManageID string) string { return overwriteTitle } -func removeForm(formManageID string) { - _, err := db.Exec("DELETE FROM form_manage WHERE form_manage_id = $1", formManageID) - if err != nil { - log.Println(err) - } -} - func setAutoJoinRole(guildID string, option string, roleID string) bool { var role_exists bool var autojoinroles_exists bool diff --git a/tool.go b/tool.go index f5e7b6f..d328ec0 100644 --- a/tool.go +++ b/tool.go @@ -158,17 +158,10 @@ func respondEmbed(interaction *discordgo.Interaction, embed discordgo.MessageEmb }) } -func checkMessageNotExists(channelID, messageID string) bool { - _, err := bot.ChannelMessage(channelID, messageID) - if err != nil { - return true - } - return false -} - func findAndDeleteUnusedMessages() { for _, message := range getAllSavedMessages() { - if checkMessageNotExists(message.ChannelID, message.ID) { + _, err := bot.ChannelMessage(message.ChannelID, message.ID) + if err != nil { tryDeleteUnusedMessage(message.ID) } }