added forms fully with disgo
This commit is contained in:
39
cmd_form.go
39
cmd_form.go
@@ -111,8 +111,8 @@ var cmd_form Command = Command{
|
|||||||
if overwriteTitle != "" {
|
if overwriteTitle != "" {
|
||||||
title = overwriteTitle
|
title = overwriteTitle
|
||||||
}
|
}
|
||||||
if data.Channel("accept_channel").ID.String() != "0" {
|
if data.Channel("approve_channel").ID.String() != "0" {
|
||||||
acceptChannelID = data.Channel("accept_channel").ID.String()
|
acceptChannelID = data.Channel("approve_channel").ID.String()
|
||||||
}
|
}
|
||||||
modsCanAnswer = data.Bool("mods_can_answer")
|
modsCanAnswer = data.Bool("mods_can_answer")
|
||||||
|
|
||||||
@@ -250,23 +250,16 @@ var cmd_form Command = Command{
|
|||||||
Build())
|
Build())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
logrus.Debug(result.AcceptChannelID)
|
||||||
if result.AcceptChannelID == "" {
|
if result.AcceptChannelID == "" {
|
||||||
var buttons []discord.ButtonComponent
|
|
||||||
var components []discord.ContainerComponent
|
|
||||||
if result.CommentCategoryID != "" {
|
|
||||||
buttons = []discord.ButtonComponent{discord.
|
|
||||||
NewButton(discord.ButtonStylePrimary, "Comment", "form:"+form_manage_id+";comment", "").
|
|
||||||
WithEmoji(discord.ComponentEmoji{Name: "👥"})}
|
|
||||||
for _, button := range buttons {
|
|
||||||
components = append(components, discord.NewActionRow(button))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_, err := e.Client().Rest().CreateMessage(snowflake.MustParse(result.ResultChannelID), discord.NewMessageCreateBuilder().
|
_, err := e.Client().Rest().CreateMessage(snowflake.MustParse(result.ResultChannelID), discord.NewMessageCreateBuilder().
|
||||||
SetEmbeds(discord.NewEmbedBuilder().
|
SetEmbeds(discord.NewEmbedBuilder().
|
||||||
SetAuthorName(*e.User().GlobalName).SetAuthorIcon(*e.User().AvatarURL()).SetTitle("\""+modal.Title+"\"").SetDescription("This is the submitted result").
|
SetAuthorName(*e.User().GlobalName).SetAuthorIcon(*e.User().AvatarURL()).SetTitle("\""+modal.Title+"\"").SetDescription("This is the submitted result").
|
||||||
SetColor(hexToDecimal(color["primary"])).SetFields(fields...).
|
SetColor(hexToDecimal(color["primary"])).SetFields(fields...).
|
||||||
Build()).
|
Build()).
|
||||||
SetContainerComponents(components...).
|
SetContainerComponents(discord.NewActionRow(discord.
|
||||||
|
NewButton(discord.ButtonStylePrimary, "Comment", "form:"+form_manage_id+";comment", "").
|
||||||
|
WithEmoji(discord.ComponentEmoji{Name: "👥"}))).
|
||||||
Build())
|
Build())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
@@ -277,28 +270,25 @@ var cmd_form Command = Command{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var buttons []discord.ButtonComponent
|
logrus.Debug("HEERE")
|
||||||
|
var buttons []discord.InteractiveComponent
|
||||||
if result.CommentCategoryID != "" {
|
if result.CommentCategoryID != "" {
|
||||||
buttons = []discord.ButtonComponent{discord.
|
buttons = []discord.InteractiveComponent{discord.
|
||||||
NewButton(discord.ButtonStylePrimary, "Comment", "form:"+form_manage_id+";comment", "").
|
NewButton(discord.ButtonStylePrimary, "Comment", "form:"+form_manage_id+";comment", "").
|
||||||
WithEmoji(discord.ComponentEmoji{Name: "👥"})}
|
WithEmoji(discord.ComponentEmoji{Name: "👥"})}
|
||||||
}
|
}
|
||||||
buttons = append(buttons, discord.
|
buttons = append(buttons, discord.
|
||||||
NewButton(discord.ButtonStylePrimary, "Decline", "form:"+form_manage_id+";decline", "").
|
NewButton(discord.ButtonStyleDanger, "Decline", "form:"+form_manage_id+";decline", "").
|
||||||
WithEmoji(discord.ComponentEmoji{Name: "🛑"}),
|
WithEmoji(discord.ComponentEmoji{Name: "🛑"}),
|
||||||
discord.
|
discord.
|
||||||
NewButton(discord.ButtonStylePrimary, "Approve", "form:"+form_manage_id+";approve", "").
|
NewButton(discord.ButtonStyleSuccess, "Approve", "form:"+form_manage_id+";approve", "").
|
||||||
WithEmoji(discord.ComponentEmoji{Name: "🎉"}))
|
WithEmoji(discord.ComponentEmoji{Name: "🎉"}))
|
||||||
var components []discord.ContainerComponent
|
|
||||||
for _, button := range buttons {
|
|
||||||
components = append(components, discord.NewActionRow(button))
|
|
||||||
}
|
|
||||||
_, err := e.Client().Rest().CreateMessage(snowflake.MustParse(result.AcceptChannelID), discord.NewMessageCreateBuilder().
|
_, err := e.Client().Rest().CreateMessage(snowflake.MustParse(result.AcceptChannelID), discord.NewMessageCreateBuilder().
|
||||||
SetEmbeds(discord.NewEmbedBuilder().
|
SetEmbeds(discord.NewEmbedBuilder().
|
||||||
SetAuthorName(*e.User().GlobalName).SetAuthorIcon(*e.User().AvatarURL()).SetTitle("\""+modal.Title+"\"").SetDescription("**This submission needs approval.**").
|
SetAuthorName(*e.User().GlobalName).SetAuthorIcon(*e.User().AvatarURL()).SetTitle("\""+modal.Title+"\"").SetDescription("**This submission needs approval.**").
|
||||||
SetColor(hexToDecimal(color["primary"])).SetFields(fields...).
|
SetColor(hexToDecimal(color["primary"])).SetFields(fields...).
|
||||||
Build()).
|
Build()).
|
||||||
SetContainerComponents(components...).
|
SetContainerComponents(discord.NewActionRow(buttons...)).
|
||||||
Build())
|
Build())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -410,8 +400,8 @@ var cmd_ticket_form Command = Command{
|
|||||||
|
|
||||||
// moderator can be userID as well as roleID
|
// moderator can be userID as well as roleID
|
||||||
func createFormComment(form_manage_id string, author snowflake.ID, moderator snowflake.ID, commentName string, embed discord.Embed, guildID snowflake.ID, client bot.Client) discord.Channel {
|
func createFormComment(form_manage_id string, author snowflake.ID, moderator snowflake.ID, commentName string, embed discord.Embed, guildID snowflake.ID, client bot.Client) discord.Channel {
|
||||||
var category snowflake.ID
|
var category snowflake.ID = snowflake.MustParse(getFormResultValues(form_manage_id).CommentCategoryID)
|
||||||
_, err := client.Rest().GetChannel(snowflake.MustParse(getFormResultValues(form_manage_id).CommentCategoryID))
|
_, err := client.Rest().GetChannel(category)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c, err := client.Rest().CreateGuildChannel(guildID, discord.GuildCategoryChannelCreate{Name: strings.Trim(embed.Title, "\"") + " mod " + commentName + "s"})
|
c, err := client.Rest().CreateGuildChannel(guildID, discord.GuildCategoryChannelCreate{Name: strings.Trim(embed.Title, "\"") + " mod " + commentName + "s"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -456,6 +446,7 @@ func createFormComment(form_manage_id string, author snowflake.ID, moderator sno
|
|||||||
if isIDRole(client, guildID, moderator) {
|
if isIDRole(client, guildID, moderator) {
|
||||||
modTypeChar = "&"
|
modTypeChar = "&"
|
||||||
}
|
}
|
||||||
|
embed.Description = "This was submitted"
|
||||||
_, err = client.Rest().CreateMessage(ch.ID(), discord.NewMessageCreateBuilder().
|
_, err = client.Rest().CreateMessage(ch.ID(), discord.NewMessageCreateBuilder().
|
||||||
SetContent("<@"+modTypeChar+moderator.String()+"> <@"+author.String()+">").SetEmbeds(embed).
|
SetContent("<@"+modTypeChar+moderator.String()+"> <@"+author.String()+">").SetEmbeds(embed).
|
||||||
Build())
|
Build())
|
||||||
|
15
cmd_info.go
15
cmd_info.go
@@ -63,8 +63,11 @@ var cmd_userinfo Command = Command{
|
|||||||
Interact: func(e *events.ApplicationCommandInteractionCreate) {
|
Interact: func(e *events.ApplicationCommandInteractionCreate) {
|
||||||
switch *e.SlashCommandInteractionData().SubCommandName {
|
switch *e.SlashCommandInteractionData().SubCommandName {
|
||||||
case "user":
|
case "user":
|
||||||
var user discord.User = e.SlashCommandInteractionData().User("user")
|
user, err := e.Client().Rest().GetUser(e.SlashCommandInteractionData().User("user").ID)
|
||||||
var userHasFlags string = fetchFlagStrings(user)
|
if err != nil {
|
||||||
|
logrus.Error(err)
|
||||||
|
}
|
||||||
|
var userHasFlags string = fetchFlagStrings(*user)
|
||||||
var userType string = "User"
|
var userType string = "User"
|
||||||
if user.Bot {
|
if user.Bot {
|
||||||
userType = "Unverified Bot"
|
userType = "Unverified Bot"
|
||||||
@@ -75,7 +78,7 @@ var cmd_userinfo Command = Command{
|
|||||||
userType = "System"
|
userType = "System"
|
||||||
}
|
}
|
||||||
embedBuilder := discord.NewEmbedBuilder()
|
embedBuilder := discord.NewEmbedBuilder()
|
||||||
embedBuilder.SetThumbnail(checkDefaultPb(user))
|
embedBuilder.SetThumbnail(checkDefaultPb(*user) + "?size=4096")
|
||||||
embedBuilder.AddField("ID", user.ID.String(), false)
|
embedBuilder.AddField("ID", user.ID.String(), false)
|
||||||
embedBuilder.AddField("Type", userType, true)
|
embedBuilder.AddField("Type", userType, true)
|
||||||
if user.GlobalName != nil {
|
if user.GlobalName != nil {
|
||||||
@@ -99,14 +102,12 @@ var cmd_userinfo Command = Command{
|
|||||||
embedBuilder.AddField("Created at", creation, false)
|
embedBuilder.AddField("Created at", creation, false)
|
||||||
|
|
||||||
if user.BannerURL() != nil {
|
if user.BannerURL() != nil {
|
||||||
value := fmt.Sprint(*user.BannerURL())
|
embedBuilder.SetImage(*user.BannerURL() + "?size=4096")
|
||||||
embedBuilder.SetImage(value)
|
|
||||||
}
|
}
|
||||||
embedBuilder.SetTitle("User info")
|
embedBuilder.SetTitle("User info")
|
||||||
embedBuilder.SetDescription(user.Mention())
|
embedBuilder.SetDescription(user.Mention())
|
||||||
embedBuilder.SetColor(hexToDecimal(color["primary"]))
|
embedBuilder.SetColor(hexToDecimal(color["primary"]))
|
||||||
embedBuilder.SetFooterText("Currently a bit broken because of Discord's constant user API changes")
|
err = e.CreateMessage(discord.NewMessageCreateBuilder().
|
||||||
err := e.CreateMessage(discord.NewMessageCreateBuilder().
|
|
||||||
SetEmbeds(embedBuilder.Build()).
|
SetEmbeds(embedBuilder.Build()).
|
||||||
Build())
|
Build())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user