12345678910111213141516171819202122232425262728293031323334353637383940 |
- 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)
- }
- }
|