Skip to content

Commit

Permalink
Merge pull request #111 from ritsec/dquery-command
Browse files Browse the repository at this point in the history
Dquery command
  • Loading branch information
c0untingNumbers committed May 6, 2024
2 parents 5eb649c + 74c6340 commit 6e6ce95
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion commands/enabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func populateScheduledEvents(ctx ddtrace.SpanContext) {
defer span.Finish()

// Populate the scheduled events
ScheduledEvents["goodfood"] = scheduled.GoodFood
// ScheduledEvents["goodfood"] = scheduled.GoodFood
ScheduledEvents["heartbeat"] = scheduled.Heartbeat
ScheduledEvents["status"] = scheduled.Status
ScheduledEvents["update"] = scheduled.Update
Expand Down
17 changes: 15 additions & 2 deletions commands/slash/dquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
func DQuery() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *discordgo.InteractionCreate)) {
return &discordgo.ApplicationCommand{
Name: "dquery",
Description: "Query users by signins on specific date and outputs to CSV file",
Description: "Query usernames by signins on specific date and outputs to CSV file",
DefaultMemberPermissions: &permission.IGLead,
Options: []*discordgo.ApplicationCommandOption{
{
Expand Down Expand Up @@ -142,8 +142,21 @@ func DQuery() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *disc

// Parsing the date as time.Time
dateToQuery, err := time.Parse("2006-01-02", dateRequested)

//Inform user that the date format is incorrect and exit
if err != nil {
logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err})
err = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Flags: discordgo.MessageFlagsEphemeral,
Content: "Date format is invalid. It needs to be YYYY-MM-DD, e.g., 2003-05-12.",
},
})
if err != nil {
logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err})
return
}
return
}

Expand All @@ -157,7 +170,6 @@ func DQuery() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *disc
return
}

message := ""
// Initial message
err = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Expand All @@ -171,6 +183,7 @@ func DQuery() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *disc
}

// Processing
message := ""
for x, signin := range signins {

// Wait for 1 seconds after every 8 user's username is called
Expand Down

0 comments on commit 6e6ce95

Please sign in to comment.