Struct twilight_http::request::channel::invite::create_invite::CreateInvite [−][src]
pub struct CreateInvite<'a> { /* fields omitted */ }
Expand description
Create an invite, with options.
Requires the CREATE_INVITE
permission.
Examples
use twilight_http::Client;
use twilight_model::id::ChannelId;
let client = Client::new("my token".to_owned());
let channel_id = ChannelId(123);
let invite = client
.create_invite(channel_id)
.max_uses(3)?
.exec()
.await?;
Implementations
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::ChannelId;
let client = Client::new(env::var("DISCORD_TOKEN")?);
let invite = client.create_invite(ChannelId(1))
.max_age(60 * 60)?
.exec()
.await?
.model()
.await?;
println!("invite code: {}", invite.code);
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::ChannelId;
let client = Client::new(env::var("DISCORD_TOKEN")?);
let invite = client.create_invite(ChannelId(1))
.max_uses(5)?
.exec()
.await?
.model()
.await?;
println!("invite code: {}", invite.code);
Set the target application ID for this invite.
This only works if target_type
is set to TargetType::EmbeddedApplication
.
Set the target user id for this invite.
Set the target type for this invite.
Specify true if the invite should grant temporary membership.
Defaults to false.
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). Refer to the discord docs for more information.
pub fn exec(self) -> ResponseFuture<Invite>ⓘNotable traits for ResponseFuture<T>impl<T: Unpin> Future for ResponseFuture<T> type Output = Result<Response<T>, Error>;
pub fn exec(self) -> ResponseFuture<Invite>ⓘNotable traits for ResponseFuture<T>impl<T: Unpin> Future for ResponseFuture<T> type Output = Result<Response<T>, Error>;
impl<T: Unpin> Future for ResponseFuture<T> type Output = Result<Response<T>, Error>;
Execute the request, returning a future resolving to a Response
.
Trait Implementations
Auto Trait Implementations
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
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more