Skip to content

Commit

Permalink
fix: 🐛 fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
vidhanio committed Feb 26, 2022
1 parent 16cb0d8 commit c4f0e87
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 10 deletions.
104 changes: 102 additions & 2 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
},
},
},
},
},
Expand Down
10 changes: 2 additions & 8 deletions command_verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -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] == "" {
Expand All @@ -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
}
}
4 changes: 4 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
}

0 comments on commit c4f0e87

Please sign in to comment.