mirror of
https://github.com/diamondburned/cchat-discord.git
synced 2024-11-01 12:24:15 +00:00
41 lines
868 B
Go
41 lines
868 B
Go
package reference
|
|
|
|
import (
|
|
"github.com/diamondburned/arikawa/v2/discord"
|
|
"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())
|
|
}
|