From c4f0e87a5aeb51b20a2ac408215ec78d1c88db5c Mon Sep 17 00:00:00 2001 From: Vidhan Bhatt Date: Sat, 26 Feb 2022 00:18:34 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20fix=20some=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- command.go | 104 +++++++++++++++++++++++++++++++++++++++++++++- command_verify.go | 10 +---- utils.go | 4 ++ 3 files changed, 108 insertions(+), 10 deletions(-) diff --git a/command.go b/command.go index 04edae4..f038ca7 100644 --- a/command.go +++ b/command.go @@ -105,8 +105,58 @@ var commands = []*discordgo.ApplicationCommand{ { Type: discordgo.ApplicationCommandOptionInteger, Name: "grade", - Description: "Grade. [1 - 12]", + Description: "Grade.", Required: true, + Choices: []*discordgo.ApplicationCommandOptionChoice{ + { + Name: "1", + Value: 1, + }, + { + Name: "2", + Value: 2, + }, + { + Name: "3", + Value: 3, + }, + { + Name: "4", + Value: 4, + }, + { + Name: "5", + Value: 5, + }, + { + Name: "6", + Value: 6, + }, + { + Name: "7", + Value: 7, + }, + { + Name: "8", + Value: 8, + }, + { + Name: "9", + Value: 9, + }, + { + Name: "10", + Value: 10, + }, + { + Name: "11", + Value: 11, + }, + { + Name: "12", + Value: 12, + }, + }, }, { Type: discordgo.ApplicationCommandOptionRole, @@ -144,8 +194,58 @@ var commands = []*discordgo.ApplicationCommand{ { Type: discordgo.ApplicationCommandOptionInteger, Name: "grade", - Description: "Grade. [1 - 12]", + Description: "Grade.", Required: true, + Choices: []*discordgo.ApplicationCommandOptionChoice{ + { + Name: "1", + Value: 1, + }, + { + Name: "2", + Value: 2, + }, + { + Name: "3", + Value: 3, + }, + { + Name: "4", + Value: 4, + }, + { + Name: "5", + Value: 5, + }, + { + Name: "6", + Value: 6, + }, + { + Name: "7", + Value: 7, + }, + { + Name: "8", + Value: 8, + }, + { + Name: "9", + Value: 9, + }, + { + Name: "10", + Value: 10, + }, + { + Name: "11", + Value: 11, + }, + { + Name: "12", + Value: 12, + }, + }, }, }, }, diff --git a/command_verify.go b/command_verify.go index c25223c..0d1fc5a 100644 --- a/command_verify.go +++ b/command_verify.go @@ -42,20 +42,16 @@ func (c *Checkpoint) verify(s *discordgo.Session, i *discordgo.InteractionCreate return } - successRespond(s, i, "You have been verified!") - err = c.session.GuildMemberRoleAdd(i.GuildID, i.Member.User.ID, g.VerifiedRole) if err != nil { errorRespond(s, i, err) - - return } + successRespond(s, i, "You have been verified!") + err = c.session.GuildMemberNickname(i.GuildID, i.Member.User.ID, fmt.Sprintf("%s %b.", firstName, lastName[0])) if err != nil { errorRespond(s, i, err) - - return } if g.GradeRoles[grade-1] == "" { @@ -65,7 +61,5 @@ func (c *Checkpoint) verify(s *discordgo.Session, i *discordgo.InteractionCreate err = c.session.GuildMemberRoleAdd(i.GuildID, i.Member.User.ID, g.GradeRoles[grade-1]) if err != nil { errorRespond(s, i, err) - - return } } diff --git a/utils.go b/utils.go index c293afd..cff875a 100644 --- a/utils.go +++ b/utils.go @@ -134,5 +134,9 @@ func warningRespond(s *discordgo.Session, i *discordgo.InteractionCreate, m stri } func errorRespond(s *discordgo.Session, i *discordgo.InteractionCreate, err error) { + log.Error(). + Err(err). + Msg("Error occured") + respond(s, i, ephemeralify(embedResponse(errorEmbed(err)))) }