Struct serenity::builder::CreateInvite [−][src]
Expand description
A builder to create a RichInvite
for use via GuildChannel::create_invite
.
This is a structured and cleaner way of creating an invite, as all parameters are optional.
Examples
Create an invite with a max age of 3600 seconds and 10 max uses:
struct Handler; #[serenity::async_trait] impl EventHandler for Handler { async fn message(&self, context: Context, msg: Message) { if msg.content == "!createinvite" { let channel = match context.cache.guild_channel(msg.channel_id).await { Some(channel) => channel, None => { let _ = msg.channel_id.say(&context, "Error creating invite").await; return; }, }; let creation = channel.create_invite(&context, |i| { i.max_age(3600).max_uses(10) }) .await; let invite = match creation { Ok(invite) => invite, Err(why) => { println!("Err creating invite: {:?}", why); if let Err(why) = msg .channel_id .say(&context, "Error creating invite") .await { println!("Err sending err msg: {:?}", why); } return; }, }; let content = format!("Here's your invite: {}", invite.url()); let _ = msg.channel_id.say(&context, &content).await; } } } let mut client =Client::builder("token").event_handler(Handler).await?; client.start().await?;
Implementations
The duration that the invite will be valid for.
Set to 0
for an invite which does not expire after an amount of time.
Defaults to 86400
, or 24 hours.
Examples
Create an invite with a max age of 3600
seconds, or 1 hour:
let invite = channel.create_invite(context, |i| { i.max_age(3600) }) .await?;
The number of uses that the invite will be valid for.
Set to 0
for an invite which does not expire after a number of uses.
Defaults to 0
.
Examples
Create an invite with a max use limit of 5
:
let invite = channel.create_invite(context, |i| { i.max_uses(5) }) .await?;
Whether an invite grants a temporary membership.
Defaults to false
.
Examples
Create an invite which is temporary:
let invite = channel.create_invite(context, |i| { i.temporary(true) }) .await?;
Trait Implementations
Creates a builder with default values, setting validate
to null
.
Examples
Create a default CreateInvite
builder:
use serenity::builder::CreateInvite; let invite_builder = CreateInvite::default();
Auto Trait Implementations
impl RefUnwindSafe for CreateInvite
impl Send for CreateInvite
impl Sync for CreateInvite
impl Unpin for CreateInvite
impl UnwindSafe for CreateInvite
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self
pub fn vzip(self) -> V