-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfun.go
59 lines (50 loc) · 1.42 KB
/
fun.go
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"fmt"
"math/rand/v2"
"os"
"strings"
"time"
"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/events"
)
func joel(event *events.ApplicationCommandInteractionCreate, joel string) {
joel = strings.TrimSpace(joel)
path, ok := ASSETS_PATHS[joel]
if !ok || joel == "" {
n := rand.IntN(len(ASSETS) - 1)
joel = ASSETS[n]
path = ASSETS_PATHS[joel]
}
image, err := os.Open(path)
if err != nil {
fmt.Printf("Error opening file: %v\n", err)
return
}
defer image.Close()
message := discord.NewMessageCreateBuilder().SetContent(joel).AddFile(image.Name(), image.Name(), image).Build()
sendMessage(event, message)
}
func ttj(event *events.ApplicationCommandInteractionCreate) {
now := time.Now()
err := event.DeferCreateMessage(false)
if err != nil {
fmt.Printf("Error deferring message: %v\n", err)
reply(event, "An error occurred while deferring the message.")
return
}
since := time.Until(now)
ttj := fmt.Sprintf("TTJ took %dms", since.Abs().Milliseconds())
fmt.Println(ttj)
image, err := os.Open("./assets/Joel.webp")
if err != nil {
fmt.Printf("Error opening file: %v\n", err)
return
}
defer image.Close()
message := discord.NewMessageCreateBuilder().SetContent(ttj).AddFile(image.Name(), image.Name(), image).Build()
_, err = CLIENT.Rest.CreateFollowupMessage(event.ApplicationID(), event.Token(), message)
if err != nil {
fmt.Printf("Error replying: %v\n", err)
}
}