Expand description
Discord message link expansion.
This module provides functionality for parsing Discord message links and generating embed previews of the linked messages.
Migrated from preview.rs with support for multiple link expansion.
Re-exportsΒ§
use futures_util::future::join_all;πuse futures_util::future::try_join_all;πuse regex::Regex;πuse std::collections::HashMap;πuse std::collections::HashSet;πuse std::sync::LazyLock;πuse twilight_http::error::ErrorType;πuse twilight_model::channel::message::Embed;πuse twilight_model::channel::permission_overwrite::PermissionOverwrite;πuse twilight_model::channel::permission_overwrite::PermissionOverwriteType;πuse twilight_model::channel::Channel;πuse twilight_model::channel::ChannelType;πuse twilight_model::channel::Message;πuse twilight_model::guild::Permissions;πuse twilight_model::id::Id;πuse twilight_model::id::marker::ChannelMarker;πuse twilight_model::id::marker::GuildMarker;πuse twilight_model::id::marker::MessageMarker;πuse twilight_model::id::marker::RoleMarker;πuse twilight_model::id::marker::UserMarker;πuse twilight_model::user::User;πuse twilight_util::builder::embed::EmbedAuthorBuilder;πuse twilight_util::builder::embed::EmbedBuilder;πuse twilight_util::builder::embed::ImageSource;πuse super::ExpandContext;πuse super::ExpandError;πuse super::ExpandedContent;πuse super::LinkExpander;πuse crate::cache::CacheArgs;πuse crate::cache::RolePermissions;πuse crate::config::BabyriteConfig;πuse crate::context::BotContext;π
StructsΒ§
- Channel
Overwrites π - A channelβs permission overwrites, split by what they target and masked to the permissions that matter for that channel.
- Discord
Expander - Discord message link expander.
- Message
LinkI Ds - Parsed IDs from a Discord message link.
- Preview
- A preview containing the message and its channel.
- Role
Grant π - What a set of roles contributes to a memberβs permissions in the source and target channels.
- Visibility π
- Decides whether everyone who can read the source channel could also read the target channel.
EnumsΒ§
- Preview
Error - Errors that can occur when generating a Discord message preview.
ConstantsΒ§
- MAX_
MEMBER_ πLOOKUPS - Most members
check_visibilitylooks up for a single link. - NO_
OVERWRITE π - PREVIEW_
EMBED_ πCOLOUR - Accent colour of a message preview embed.
- READ_
SOURCE π - Permissions a member needs to read the expanded reply in the source channel.
- READ_
TARGET π - Permissions a member needs to read the linked message in a text channel.
StaticsΒ§
- MESSAGE_
LINK_ REGEX - Regex pattern for matching Discord message links.
FunctionsΒ§
- avatar_
url π - Returns the CDN URL of
userβs avatar, orNonewhen they have none. - channel_
permissions π - Applies Discordβs permission algorithm to one channel.
- check_
visibility π - Validates that everyone who can read
source_channelcould also read the linked message inchannel. - has_
unknown_ πoverwrite - Returns
trueif any overwrite targets a kind Discord added after this library was written. - has_
unlisted_ πreaders - Returns
truewhen the readers of a channel ofkindcannot be evaluated. - is_
cross_ πguild - Returns
truewhen a link crosses a guild boundary. - is_
thread π - Returns
truefor thread channel types. - member_
roles π - Fetches the roles of
user_id, orNonewhen they are not in the guild. - overwrites π
- The permission overwrites of
channel; Discord omits the field when empty. - permission_
channel π - Resolves the channel that carries the properties a thread inherits β its permission overwrites and its NSFW flag.
- preview_
embed π - Renders a fetched message as the embed posted in the requesterβs channel.
- read_
source_ πrequirement - Permissions a member needs to read the expanded reply in the source channel,
when the link points to a channel of
target_kind. - read_
target_ πrequirement - Permissions a member needs to read the linked message in a channel of
kind.
Type AliasesΒ§
- Overwrite
Pair π - The
(allow, deny)pair of a permission overwrite.