Struct serenity::builder::CreateInvite

source ·
pub struct CreateInvite<'a> { /* private fields */ }
Available on crate feature builder only.
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:

use serenity::builder::CreateInvite;
let builder = CreateInvite::new().max_age(3600).max_uses(10);
let creation = channel.create_invite(&context, builder).await?;

Discord docs

Implementations§

source§

impl<'a> CreateInvite<'a>

source

pub fn new() -> Self

Equivalent to Self::default.

source

pub fn max_age(self, max_age: u32) -> Self

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 builder = CreateInvite::new().max_age(3600);
let invite = channel.create_invite(context, builder).await?;
source

pub fn max_uses(self, max_uses: u8) -> Self

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:

Create an invite with a max age of 3600 seconds, or 1 hour:

let builder = CreateInvite::new().max_uses(5);
let invite = channel.create_invite(context, builder).await?;
source

pub fn temporary(self, temporary: bool) -> Self

Whether an invite grants a temporary membership.

Defaults to false.

§Examples

Create an invite which is temporary:

let builder = CreateInvite::new().temporary(true);
let invite = channel.create_invite(context, builder).await?;
source

pub fn unique(self, unique: bool) -> Self

Whether or not to try to reuse a similar invite.

Defaults to false.

§Examples

Create an invite which is unique:

let builder = CreateInvite::new().unique(true);
let invite = channel.create_invite(context, builder).await?;
source

pub fn target_type(self, target_type: InviteTargetType) -> Self

The type of target for this voice channel invite.

source

pub fn target_user_id(self, target_user_id: UserId) -> Self

The ID of the user whose stream to display for this invite, required if target_type is Stream The user must be streaming in the channel.

source

pub fn target_application_id(self, target_application_id: ApplicationId) -> Self

The ID of the embedded application to open for this invite, required if target_type is EmmbeddedApplication.

The application must have the EMBEDDED flag.

When sending an invite with this value, the first user to use the invite will have to click on the URL, that will enable the buttons in the embed.

These are some of the known applications which have the flag:

betrayal: 773336526917861400 youtube: 755600276941176913 fishing: 814288819477020702 poker: 755827207812677713 chess: 832012774040141894

source

pub fn audit_log_reason(self, reason: &'a str) -> Self

Sets the request’s audit log reason.

Trait Implementations§

source§

impl<'a> Builder for CreateInvite<'a>

Available on crate feature http only.
source§

fn execute<'life0, 'async_trait>( self, cache_http: impl 'async_trait + CacheHttp, ctx: Self::Context<'life0> ) -> Pin<Box<dyn Future<Output = Result<RichInvite>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Creates an invite for the given channel.

Note: Requires the Create Instant Invite permission.

§Errors

If the cache is enabled, returns ModelError::InvalidPermissions if the current user lacks permission. Otherwise returns Error::Http, as well as if invalid data is given.

§

type Context<'ctx> = ChannelId

Additional data that’s only required when sending a request off to the API.
§

type Built = RichInvite

source§

impl<'a> Clone for CreateInvite<'a>

source§

fn clone(&self) -> CreateInvite<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for CreateInvite<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> Default for CreateInvite<'a>

source§

fn default() -> CreateInvite<'a>

Returns the “default value” for a type. Read more
source§

impl<'a> Serialize for CreateInvite<'a>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for CreateInvite<'a>

§

impl<'a> RefUnwindSafe for CreateInvite<'a>

§

impl<'a> Send for CreateInvite<'a>

§

impl<'a> Sync for CreateInvite<'a>

§

impl<'a> Unpin for CreateInvite<'a>

§

impl<'a> UnwindSafe for CreateInvite<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneDebuggableStorage for T

source§

impl<T> CloneableStorage for T
where T: Any + Send + Sync + Clone,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DebuggableStorage for T
where T: Any + Send + Sync + Debug,