continued working on forms
This commit is contained in:
31
cmd_form.go
31
cmd_form.go
@@ -101,22 +101,34 @@ var form_command Command = Command{
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
case "add":
|
case "add":
|
||||||
var optionName string = i.ApplicationCommandData().Options[0].Options[0].Name
|
var title string
|
||||||
var optionValue string = i.ApplicationCommandData().Options[0].Options[0].StringValue()
|
var optionValue string
|
||||||
if optionName == "" { // handling optional empty
|
if len(i.ApplicationCommandData().Options[0].Options) == 0 {
|
||||||
optionName = "General"
|
optionValue = "template_general"
|
||||||
|
} else {
|
||||||
|
optionValue = i.ApplicationCommandData().Options[0].Options[0].StringValue()
|
||||||
|
}
|
||||||
|
switch optionValue {
|
||||||
|
case "template_feedback":
|
||||||
|
title = "Submit Feedback"
|
||||||
|
case "template_ticket":
|
||||||
|
title = "Make a new ticket"
|
||||||
|
case "template_url":
|
||||||
|
title = "Add your URL"
|
||||||
|
case "template_general":
|
||||||
|
title = "Form"
|
||||||
}
|
}
|
||||||
s.ChannelMessageSendComplex(i.ChannelID, &discordgo.MessageSend{
|
s.ChannelMessageSendComplex(i.ChannelID, &discordgo.MessageSend{
|
||||||
Embed: &discordgo.MessageEmbed{
|
Embed: &discordgo.MessageEmbed{
|
||||||
Color: hexToDecimal(color["primary"]),
|
Color: hexToDecimal(color["primary"]),
|
||||||
Title: optionName,
|
Title: title,
|
||||||
Description: "Press the bottom button to open a form popup.",
|
Description: "Press the bottom button to open a form popup.",
|
||||||
},
|
},
|
||||||
Components: []discordgo.MessageComponent{
|
Components: []discordgo.MessageComponent{
|
||||||
discordgo.ActionsRow{
|
discordgo.ActionsRow{
|
||||||
Components: []discordgo.MessageComponent{
|
Components: []discordgo.MessageComponent{
|
||||||
discordgo.Button{
|
discordgo.Button{
|
||||||
CustomID: "form:" + optionValue,
|
CustomID: "form:", //add formID
|
||||||
Label: "Submit",
|
Label: "Submit",
|
||||||
Emoji: discordgo.ComponentEmoji{
|
Emoji: discordgo.ComponentEmoji{
|
||||||
Name: "📥",
|
Name: "📥",
|
||||||
@@ -126,6 +138,13 @@ var form_command Command = Command{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||||
|
Data: &discordgo.InteractionResponseData{
|
||||||
|
Content: "Successfully added form button!",
|
||||||
|
Flags: discordgo.MessageFlagsEphemeral,
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ComponentIDs: getFormIDs(),
|
ComponentIDs: getFormIDs(),
|
||||||
|
@@ -29,11 +29,15 @@ func initTables() {
|
|||||||
PRIMARY KEY (form_id, guild_id)
|
PRIMARY KEY (form_id, guild_id)
|
||||||
);
|
);
|
||||||
CREATE TABLE IF NOT EXISTS formbuttons (
|
CREATE TABLE IF NOT EXISTS formbuttons (
|
||||||
|
form_manage_id TEXT NOT NULL,
|
||||||
form_id TEXT NOT NULL,
|
form_id TEXT NOT NULL,
|
||||||
|
overwrite_title TEXT NOT NULL,
|
||||||
message_id TEXT NOT NULL,
|
message_id TEXT NOT NULL,
|
||||||
channel_id TEXT NOT NULL,
|
channel_id TEXT NOT NULL,
|
||||||
guild_id TEXT NOT NULL,
|
guild_id TEXT NOT NULL,
|
||||||
PRIMARY KEY (form_id, guild_id, channel_id)
|
result_channel_id TEXT NOT NULL,
|
||||||
|
accept_channel_id TEXT NOT NULL,
|
||||||
|
PRIMARY KEY (form_manage_id, form_id)
|
||||||
);
|
);
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -175,3 +179,7 @@ func removeSticky(guildID string, channelID string) {
|
|||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addTemplateForm(guildID string, channelID string, formID string, overwriteChannelID string, resultChannelID string, acceptChannelID string) {
|
||||||
|
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user