added ping command
This commit is contained in:
@@ -16,12 +16,10 @@ var ping_command Command = Command{
|
|||||||
Interact: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
Interact: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
// Create a new HTTP client with a timeout
|
|
||||||
client := http.Client{
|
client := http.Client{
|
||||||
Timeout: 5 * time.Second,
|
Timeout: 5 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send a GET request to the Discord API
|
|
||||||
resp, err := client.Get("https://discord.com/api/v9/gateway/bot")
|
resp, err := client.Get("https://discord.com/api/v9/gateway/bot")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error:", err)
|
fmt.Println("Error:", err)
|
||||||
@@ -29,7 +27,6 @@ var ping_command Command = Command{
|
|||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
// Calculate the ping
|
|
||||||
ping := time.Since(start)
|
ping := time.Since(start)
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||||
|
Reference in New Issue
Block a user