-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.go
More file actions
69 lines (51 loc) · 1.09 KB
/
util.go
File metadata and controls
69 lines (51 loc) · 1.09 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
69
package main
import (
"fmt"
dg "github.com/bwmarrin/discordgo"
)
const (
err_max int = 128
)
func check_error(e error) {
if e != nil {
panic(e)
}
}
func trunc_err(e string) string {
if len(e) > err_max-3 {
return e[:err_max-3] + "..."
} else {
return e
}
}
func gen_interaction_log(command_name string, i *dg.InteractionCreate) string {
var user_obj *dg.User
if i.User == nil {
user_obj = i.Member.User
} else {
user_obj = i.User
}
return fmt.Sprintf("/%s used by %s in %s", command_name, user_obj.ID, i.ChannelID)
}
func resolve_user(i *dg.InteractionCreate) *dg.User {
if i.User == nil {
return i.Member.User
} else {
return i.User
}
}
// Sends a default response, avoids boilerplate.
func default_resp(s *dg.Session, i *dg.Interaction, message_string string, title string) {
s.InteractionRespond(i, &dg.InteractionResponse{
Type: dg.InteractionResponseChannelMessageWithSource,
Data: &dg.InteractionResponseData{
Embeds: []*dg.MessageEmbed{
{
Title: title,
Description: message_string,
Color: 1976635,
},
},
},
})
}