1
0
Fork 0
mirror of https://github.com/diamondburned/cchat-discord.git synced 2024-11-01 20:34:27 +00:00
cchat-discord/internal/segments/reference/reference.go

41 lines
868 B
Go
Raw Normal View History

2020-12-19 05:46:12 +00:00
package reference
import (
2020-12-20 05:44:26 +00:00
"github.com/diamondburned/arikawa/v2/discord"
2020-12-19 05:46:12 +00:00
"github.com/diamondburned/cchat"
"github.com/diamondburned/cchat/text"
"github.com/diamondburned/cchat/utils/empty"
)
type MessageID cchat.ID
var _ text.MessageReferencer = (*MessageID)(nil)
func (msgID MessageID) MessageID() string {
return string(msgID)
}
type MessageSegment struct {
empty.TextSegment
start, end int
messageID discord.MessageID
}
var _ text.Segment = (*MessageSegment)(nil)
func NewMessageSegment(start, end int, msgID discord.MessageID) MessageSegment {
return MessageSegment{
start: start,
end: end,
messageID: msgID,
}
}
func (msgseg MessageSegment) Bounds() (start, end int) {
return msgseg.start, msgseg.end
}
func (msgseg MessageSegment) AsMessageReferencer() text.MessageReferencer {
return MessageID(msgseg.messageID.String())
}