pub struct Preview {
pub message: Message,
pub channel: Channel,
}Expand description
A preview containing the message and its channel.
Fields§
§message: MessageThe message to preview.
channel: ChannelThe channel containing the message.
Implementations§
Source§impl Preview
impl Preview
Sourceasync fn get(
args: &MessageLinkIDs,
ctx: &BotContext,
guild_id: Id<GuildMarker>,
source_channel: &Channel,
) -> Result<Preview, PreviewError>
async fn get( args: &MessageLinkIDs, ctx: &BotContext, guild_id: Id<GuildMarker>, source_channel: &Channel, ) -> Result<Preview, PreviewError>
Retrieves a preview for the given message link.
Every rule deciding whether a link may be expanded lives here. In order,
the link must point into guild_id — the guild of source_channel —
and the linked channel must not be NSFW, must not be a DM or a private
thread other than source_channel, and must be readable by everyone who
can view source_channel. The expanded content is posted as a single
message that all members of source_channel can read, so the linked channel must be at least as
visible as the source channel to avoid leaking restricted content. Public
and news threads are judged by their parent channel, which holds both the
permission overwrites and the NSFW flag they inherit.
The guild boundary is checked before the channel is resolved. Roles and permission overwrites are guild-local, so a link into another guild cannot be judged at all, and resolving it would spend rate limit on a guild the bot may not even be in.
A link back into source_channel is not exempt: its readers may lack
READ_MESSAGE_HISTORY there, and the reply would show them an older
message.