[−][src]Struct serenity::builder::CreateInvite
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
impl CreateInvite
[src]
pub fn max_age(&mut self, max_age: u64) -> &mut Self
[src]
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?;
pub fn max_uses(&mut self, max_uses: u64) -> &mut Self
[src]
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?;
pub fn temporary(&mut self, temporary: bool) -> &mut Self
[src]
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?;
pub fn unique(&mut self, unique: bool) -> &mut Self
[src]
Whether or not to try to reuse a similar invite.
Defaults to false
.
Examples
Create an invite which is unique:
let invite = channel.create_invite(context, |i| { i.unique(true) }) .await?;
Trait Implementations
impl Clone for CreateInvite
[src]
pub fn clone(&self) -> CreateInvite
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for CreateInvite
[src]
impl Default for CreateInvite
[src]
pub fn default() -> CreateInvite
[src]
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
[src]
impl Send for CreateInvite
[src]
impl Sync for CreateInvite
[src]
impl Unpin for CreateInvite
[src]
impl UnwindSafe for CreateInvite
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
pub fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,