-
Notifications
You must be signed in to change notification settings - Fork 1
/
role_info.go
79 lines (73 loc) · 1.56 KB
/
role_info.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// SPDX-License-Identifier: AGPL-3.0-only
package info
import (
"fmt"
"strings"
"github.com/diamondburned/arikawa/v3/discord"
"github.com/starshine-sys/bcr"
"github.com/starshine-sys/tribble/common"
)
func (bot *Bot) roleInfo(ctx *bcr.Context) (err error) {
r, err := ctx.ParseRole(ctx.RawArgs)
if err != nil {
_, err = ctx.Send("The specified role could not be found.")
return
}
colour := r.Color
if colour == 0 {
colour = ctx.Router.EmbedColor
}
e := discord.Embed{
Title: "Role info",
Description: "`" + r.Mention() + "`",
Color: colour,
Fields: []discord.EmbedField{
{
Name: "ID",
Value: r.ID.String(),
Inline: true,
},
{
Name: "Name",
Value: r.Name,
Inline: true,
},
{
Name: "Colour",
Value: r.Color.String(),
Inline: true,
},
{
Name: "Position",
Value: fmt.Sprint(r.Position),
Inline: true,
},
{
Name: "Mentionable",
Value: fmt.Sprint(r.Mentionable),
Inline: true,
},
{
Name: "Hoisted",
Value: fmt.Sprint(r.Hoist),
Inline: true,
},
{
Name: "Created",
Value: fmt.Sprintf("<t:%v>\n(%v)", r.ID.Time().Unix(), common.FormatTime(r.ID.Time().UTC())),
Inline: false,
},
{
Name: "Permissions",
Value: fmt.Sprintf("%v", FirstNonZero(strings.Join(bcr.PermStrings(r.Permissions), ", "), "None")),
Inline: false,
},
},
Footer: &discord.EmbedFooter{
Text: fmt.Sprintf("ID: %v | Created at", r.ID),
},
Timestamp: discord.Timestamp(r.ID.Time()),
}
_, err = ctx.Send("", e)
return
}