pub struct CreateInvite<'a> { /* private fields */ }
Expand description
Create an invite, with options.
Requires the CREATE_INVITE
permission.
§Examples
use twilight_http::Client;
use twilight_model::id::Id;
let client = Client::new("my token".to_owned());
let channel_id = Id::new(123);
let invite = client.create_invite(channel_id).max_uses(3).await?;
Implementations§
source§impl<'a> CreateInvite<'a>
impl<'a> CreateInvite<'a>
sourcepub fn max_age(self, max_age: u32) -> Self
pub fn max_age(self, max_age: u32) -> Self
Set the maximum age for an invite.
If no age is specified, Discord sets the age to 86400 seconds, or 24 hours. Set to 0 to never expire.
§Examples
Create an invite for a channel with a maximum of 1 use and an age of 1 hour:
use std::env;
use twilight_http::Client;
use twilight_model::id::Id;
let client = Client::new(env::var("DISCORD_TOKEN")?);
let invite = client
.create_invite(Id::new(1))
.max_age(60 * 60)
.await?
.model()
.await?;
println!("invite code: {}", invite.code);
§Errors
Returns an error of type InviteMaxAge
if the age is invalid.
sourcepub fn max_uses(self, max_uses: u16) -> Self
pub fn max_uses(self, max_uses: u16) -> Self
Set the maximum uses for an invite, or 0 for infinite.
Discord defaults this to 0, or infinite.
§Examples
Create an invite for a channel with a maximum of 5 uses:
use std::env;
use twilight_http::Client;
use twilight_model::id::Id;
let client = Client::new(env::var("DISCORD_TOKEN")?);
let invite = client
.create_invite(Id::new(1))
.max_uses(5)
.await?
.model()
.await?;
println!("invite code: {}", invite.code);
§Errors
Returns an error of type InviteMaxUses
if the uses is invalid.
sourcepub fn target_application_id(
self,
target_application_id: Id<ApplicationMarker>,
) -> Self
pub fn target_application_id( self, target_application_id: Id<ApplicationMarker>, ) -> Self
Set the target application ID for this invite.
This only works if target_type
is set to TargetType::EmbeddedApplication
.
sourcepub fn target_user_id(self, target_user_id: Id<UserMarker>) -> Self
pub fn target_user_id(self, target_user_id: Id<UserMarker>) -> Self
Set the target user id for this invite.
sourcepub fn target_type(self, target_type: TargetType) -> Self
pub fn target_type(self, target_type: TargetType) -> Self
Set the target type for this invite.
sourcepub fn temporary(self, temporary: bool) -> Self
pub fn temporary(self, temporary: bool) -> Self
Specify true if the invite should grant temporary membership.
Defaults to false.
sourcepub fn unique(self, unique: bool) -> Self
pub fn unique(self, unique: bool) -> Self
Specify true if the invite should be unique. Defaults to false.
If true, don’t try to reuse a similar invite (useful for creating many unique one time use invites). See Discord Docs/Create Channel Invite.