Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

134 adding the ability to query the amount of signins for a member #145

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions commands/enabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func populateSlashCommands(ctx ddtrace.SpanContext) {
SlashCommands["birthday"] = slash.Birthday
SlashCommands["dquery"] = slash.DQuery
SlashCommands["attendance"] = slash.Attendance
SlashCommands["attendanceof"] = slash.Attendanceof
}

// populateHandlers populates the Handlers map with all of the handlers
Expand Down
52 changes: 52 additions & 0 deletions commands/slash/attendanceof.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package slash

import (
"github.com/bwmarrin/discordgo"
"github.com/ritsec/ops-bot-iii/commands/slash/permission"
"github.com/ritsec/ops-bot-iii/logging"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)

//Attendanceof slash command
func Attendanceof() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *discordgo.InteractionCreate)) {
return &discordgo.ApplicationCommand {
Name: "attendanceof",
c0untingNumbers marked this conversation as resolved.
Show resolved Hide resolved
Description: "Get signin history of a user",
DefaultMemberPermissions: &permission.IGLead,
Options: []*discordgo.ApplicationCommandOption {
{
Type: discordgo.ApplicationCommandOptionUser,
Name: "user",
Description: "The user whose signin history you want to check",
Required: true,
},
},
},
func(s *discordgo.Session, i *discordgo.InteractionCreate) {
span := tracer.StartSpan(
"commands.slash.attendanceof:Attendanceof",
tracer.ResourceName("/attendanceof"),
)
defer span.Finish()

u := i.ApplicationCommandData().Options[0].UserValue(s)

logging.Debug(s, "Attendanceof command received for " + u.Username, i.Member.User, span)

err := s.InteractionRespond(
i.Interaction,
&discordgo.InteractionResponse {
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData {
Content: attendanceMessage(u.ID, span.Context()),
c0untingNumbers marked this conversation as resolved.
Show resolved Hide resolved
Flags: discordgo.MessageFlagsEphemeral,
},
},
)
if err != nil {
logging.Error(s, err.Error(), i.Member.User, span)
} else {
logging.Debug(s, "Signin History Given for " + u.Username, i.Member.User, span)
}
}
}
Loading