-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathping.go
More file actions
42 lines (38 loc) · 1.2 KB
/
ping.go
File metadata and controls
42 lines (38 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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"
)
// Ping is a slash command that responds with "Pong!"
func Ping() (*discordgo.ApplicationCommand, func(s *discordgo.Session, i *discordgo.InteractionCreate)) {
return &discordgo.ApplicationCommand{
Name: "ping",
Description: "Pong!",
DefaultMemberPermissions: &permission.Member,
},
func(s *discordgo.Session, i *discordgo.InteractionCreate) {
span := tracer.StartSpan(
"commands.slash.ping:Ping",
tracer.ResourceName("/ping"),
)
defer span.Finish()
logging.Debug(s, "Ping command received", i.Member.User, span)
err := s.InteractionRespond(
i.Interaction,
&discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: "Pong!",
Flags: discordgo.MessageFlagsEphemeral,
},
},
)
if err != nil {
logging.Error(s, err.Error(), i.Member.User, span)
} else {
logging.Debug(s, "Pong!", i.Member.User, span)
}
}
}