-
Notifications
You must be signed in to change notification settings - Fork 810
/
message_test.go
52 lines (47 loc) · 1.1 KB
/
message_test.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
package discordgo
import (
"testing"
)
func TestContentWithMoreMentionsReplaced(t *testing.T) {
s := &Session{StateEnabled: true, State: NewState()}
user := &User{
ID: "user",
Username: "User Name",
}
s.State.GuildAdd(&Guild{ID: "guild"})
s.State.RoleAdd("guild", &Role{
ID: "role",
Name: "Role Name",
Mentionable: true,
})
s.State.MemberAdd(&Member{
User: user,
Nick: "User Nick",
GuildID: "guild",
})
s.State.ChannelAdd(&Channel{
Name: "Channel Name",
GuildID: "guild",
ID: "channel",
})
m := &Message{
Content: "<@&role> <@!user> <@user> <#channel>",
ChannelID: "channel",
MentionRoles: []string{"role"},
Mentions: []*User{user},
}
if result, _ := m.ContentWithMoreMentionsReplaced(s); result != "@Role Name @User Nick @User Name #Channel Name" {
t.Error(result)
}
}
func TestGettingEmojisFromMessage(t *testing.T) {
msg := "test test <:kitty14:811736565172011058> <:kitty4:811736468812595260>"
m := &Message{
Content: msg,
}
emojis := m.GetCustomEmojis()
if len(emojis) < 1 {
t.Error("No emojis found.")
return
}
}