Trait twilight_mention::fmt::Mention
source · pub trait Mention<T> {
// Required method
fn mention(&self) -> MentionFormat<T>;
}
Expand description
Mention a resource, such as an emoji or user.
This will create a mention that will link to a user if it exists.
Look at the implementations list to see what you can mention.
§Examples
Mention a channel ID:
use twilight_mention::Mention;
use twilight_model::id::{marker::ChannelMarker, Id};
let id = Id::<ChannelMarker>::new(123);
assert_eq!("<#123>", id.mention().to_string());
Required Methods§
sourcefn mention(&self) -> MentionFormat<T>
fn mention(&self) -> MentionFormat<T>
Mention a resource by using its ID.
Implementations on Foreign Types§
source§impl Mention<Id<ChannelMarker>> for Channel
impl Mention<Id<ChannelMarker>> for Channel
Mention a channel. This will format as <#ID>
.
fn mention(&self) -> MentionFormat<Id<ChannelMarker>>
source§impl Mention<Id<ChannelMarker>> for Id<ChannelMarker>
impl Mention<Id<ChannelMarker>> for Id<ChannelMarker>
Mention a channel ID. This will format as <#ID>
.
fn mention(&self) -> MentionFormat<Id<ChannelMarker>>
source§impl Mention<Id<EmojiMarker>> for Emoji
impl Mention<Id<EmojiMarker>> for Emoji
Mention an emoji. This will format as <:emoji:ID>
.
fn mention(&self) -> MentionFormat<Id<EmojiMarker>>
source§impl Mention<Id<EmojiMarker>> for Id<EmojiMarker>
impl Mention<Id<EmojiMarker>> for Id<EmojiMarker>
Mention an emoji. This will format as <:emoji:ID>
.
fn mention(&self) -> MentionFormat<Id<EmojiMarker>>
source§impl Mention<Id<RoleMarker>> for Role
impl Mention<Id<RoleMarker>> for Role
Mention a role ID. This will format as <@&ID>
.
fn mention(&self) -> MentionFormat<Id<RoleMarker>>
source§impl Mention<Id<RoleMarker>> for Id<RoleMarker>
impl Mention<Id<RoleMarker>> for Id<RoleMarker>
Mention a role ID. This will format as <@&ID>
.
fn mention(&self) -> MentionFormat<Id<RoleMarker>>
source§impl Mention<Id<UserMarker>> for Member
impl Mention<Id<UserMarker>> for Member
Mention a member’s user. This will format as <@ID>
.
fn mention(&self) -> MentionFormat<Id<UserMarker>>
source§impl Mention<Id<UserMarker>> for Id<UserMarker>
impl Mention<Id<UserMarker>> for Id<UserMarker>
Mention a user ID. This will format as <&ID>
.
fn mention(&self) -> MentionFormat<Id<UserMarker>>
source§impl Mention<Id<UserMarker>> for CurrentUser
impl Mention<Id<UserMarker>> for CurrentUser
Mention the current user. This will format as <@ID>
.
fn mention(&self) -> MentionFormat<Id<UserMarker>>
source§impl Mention<Id<UserMarker>> for User
impl Mention<Id<UserMarker>> for User
Mention a user. This will format as <&ID>
.
fn mention(&self) -> MentionFormat<Id<UserMarker>>
Implementors§
impl Mention<CommandMention> for CommandMention
Mention a command.
This will format as:
</NAME:COMMAND_ID>
for commands</NAME SUBCOMMAND:ID>
for subcommands</NAME SUBCOMMAND_GROUP SUBCOMMAND:ID>
for subcommand groups
§Cloning
This implementation uses clone
to construct a MentionFormat
that owns the
inner CommandMention
as mention
takes a &self
.
The other implementations do this for types that are Copy
and therefore do not need to use
clone
.
To avoid cloning use CommandMention::into_mention
.
impl Mention<Timestamp> for Timestamp
Mention a timestamp. This will format as <t:UNIX>
if a style is not
specified or <t:UNIX:STYLE>
if a style is specified.