-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutilities.go
More file actions
68 lines (58 loc) · 1.54 KB
/
utilities.go
File metadata and controls
68 lines (58 loc) · 1.54 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"sort"
"time"
"github.com/bwmarrin/discordgo"
"github.com/bwmarrin/lit"
)
var answers = []string{
"It is certain",
"Reply hazy, try again",
"Don’t count on it",
"It is decidedly so",
"Ask again later",
"My reply is no",
"Without a doubt",
"Better not tell you now",
"My sources say no",
"Yes definitely",
"Cannot predict now",
"Outlook not so good",
"You may rely on it",
"Concentrate and ask again",
"Very doubtful",
"As I see it, yes",
"Most likely",
"Outlook good",
"Yes",
"Signs point to yes",
}
// Sends embed as response to an interaction
func sendEmbedInteraction(s *discordgo.Session, embed *discordgo.MessageEmbed, i *discordgo.Interaction, c chan struct{}) {
sliceEmbed := []*discordgo.MessageEmbed{embed}
_, err := s.InteractionResponseEdit(i, &discordgo.WebhookEdit{Embeds: &sliceEmbed})
if err != nil {
lit.Error("InteractionRespond failed: %s", err)
}
}
// Sends and delete after three second an embed in a given channel
func sendAndDeleteEmbedInteraction(s *discordgo.Session, embed *discordgo.MessageEmbed, i *discordgo.Interaction, wait time.Duration, c chan struct{}) {
sendEmbedInteraction(s, embed, i, c)
time.Sleep(wait)
err := s.InteractionResponseDelete(i)
if err != nil {
lit.Error("InteractionResponseDelete failed: %s", err)
return
}
}
// Sorts a map into an array
func sorting(classifica map[string]int) []kv {
var ss []kv
for k, v := range classifica {
ss = append(ss, kv{k, v})
}
sort.Slice(ss, func(i, j int) bool {
return ss[i].Value > ss[j].Value
})
return ss
}