Struct twilight_http::request::channel::invite::CreateInvite
source · [−]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)?.exec().await?;
Implementations
sourceimpl<'a> CreateInvite<'a>
impl<'a> CreateInvite<'a>
sourcepub const fn max_age(self, max_age: u32) -> Result<Self, ValidationError>
pub const fn max_age(self, max_age: u32) -> Result<Self, ValidationError>
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)?
.exec()
.await?
.model()
.await?;
println!("invite code: {}", invite.code);
Errors
Returns an error of type InviteMaxAge
if the age is invalid.
sourcepub const fn max_uses(self, max_uses: u16) -> Result<Self, ValidationError>
pub const fn max_uses(self, max_uses: u16) -> Result<Self, ValidationError>
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)?
.exec()
.await?
.model()
.await?;
println!("invite code: {}", invite.code);
Errors
Returns an error of type InviteMaxUses
if the uses is invalid.
sourcepub const fn target_application_id(
self,
target_application_id: Id<ApplicationMarker>
) -> Self
pub const 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 const fn target_user_id(self, target_user_id: Id<UserMarker>) -> Self
pub const fn target_user_id(self, target_user_id: Id<UserMarker>) -> Self
Set the target user id for this invite.
sourcepub const fn target_type(self, target_type: TargetType) -> Self
pub const fn target_type(self, target_type: TargetType) -> Self
Set the target type for this invite.
sourcepub const fn temporary(self, temporary: bool) -> Self
pub const fn temporary(self, temporary: bool) -> Self
Specify true if the invite should grant temporary membership.
Defaults to false.
sourcepub const fn unique(self, unique: bool) -> Self
pub const 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.
sourcepub 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>;
Execute the request, returning a future resolving to a Response
.
Trait Implementations
sourceimpl<'a> AuditLogReason<'a> for CreateInvite<'a>
impl<'a> AuditLogReason<'a> for CreateInvite<'a>
sourceimpl TryIntoRequest for CreateInvite<'_>
impl TryIntoRequest for CreateInvite<'_>
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more