forked from pothtonswer/discordmuffin
* update Activity struct and add emoji functions * fix the emoji regex * Remove inline type definitions * Change function name * fix message_test function name * make custom unmarshaljson and change `CreatedAt` to `time.Time` * fix Co-authored-by: post <61803796+postrequest69@users.noreply.github.com>
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
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
|
|
}
|
|
|
|
}
|