pub struct Preview {
pub message: Message,
pub channel: GuildChannel,
}Expand description
A preview containing the message and its channel.
Fields§
§message: MessageThe message to preview.
channel: GuildChannelThe channel containing the message.
Implementations§
Source§impl Preview
impl Preview
Sourceasync fn get(
args: &MessageLinkIDs,
ctx: &Context,
source_channel: &GuildChannel,
) -> Result<Preview, PreviewError>
async fn get( args: &MessageLinkIDs, ctx: &Context, source_channel: &GuildChannel, ) -> 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 the same guild as source_channel, and the
linked channel must not be NSFW, must not be a private thread or DM, and
must be viewable 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.
When the link target is the same channel as source_channel, the
visibility checks are skipped entirely: the reply lands in that same
channel, so it cannot expose anything its readers cannot already see.