pub struct CreateInvite<'a> { /* private fields */ }
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?;
Implementations§
Source§impl<'a> CreateInvite<'a>
impl<'a> CreateInvite<'a>
Sourcepub fn new() -> Self
pub fn new() -> Self
Equivalent to Self::default
.
Sourcepub fn max_age(self, max_age: u32) -> Self
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?;
Sourcepub fn max_uses(self, max_uses: u8) -> Self
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?;
Sourcepub fn temporary(self, temporary: bool) -> Self
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?;
Sourcepub fn unique(self, unique: bool) -> Self
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?;
Sourcepub fn target_type(self, target_type: InviteTargetType) -> Self
pub fn target_type(self, target_type: InviteTargetType) -> Self
The type of target for this voice channel invite.
Sourcepub fn target_user_id(self, target_user_id: UserId) -> Self
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.
Sourcepub fn target_application_id(self, target_application_id: ApplicationId) -> Self
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
Sourcepub fn audit_log_reason(self, reason: &'a str) -> Self
pub fn audit_log_reason(self, reason: &'a str) -> Self
Sets the request’s audit log reason.
Trait Implementations§
Source§impl Builder for CreateInvite<'_>
impl Builder for CreateInvite<'_>
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,
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.
Source§type Context<'ctx> = ChannelId
type Context<'ctx> = ChannelId
type Built = RichInvite
Source§impl<'a> Clone for CreateInvite<'a>
impl<'a> Clone for CreateInvite<'a>
Source§fn clone(&self) -> CreateInvite<'a>
fn clone(&self) -> CreateInvite<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more