12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- 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
- }
- }
|