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>

source

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)?
    .await?
    .model()
    .await?;

println!("invite code: {}", invite.code);
Errors

Returns an error of type InviteMaxAge if the age is invalid.

source

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)?
    .await?
    .model()
    .await?;

println!("invite code: {}", invite.code);
Errors

Returns an error of type InviteMaxUses if the uses is invalid.

source

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.

source

pub const fn target_user_id(self, target_user_id: Id<UserMarker>) -> Self

Set the target user id for this invite.

source

pub const fn target_type(self, target_type: TargetType) -> Self

Set the target type for this invite.

source

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

Specify true if the invite should grant temporary membership.

Defaults to false.

source

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.

source

pub fn exec(self) -> ResponseFuture<Invite>

👎Deprecated since 0.14.0: use .await or into_future instead

Execute the request, returning a future resolving to a Response.

Trait Implementations§

source§

impl<'a> AuditLogReason<'a> for CreateInvite<'a>

source§

fn reason(self, reason: &'a str) -> Result<Self, ValidationError>

Attach an audit log reason to the request. Read more
source§

impl IntoFuture for CreateInvite<'_>

§

type Output = Result<Response<Invite>, Error>

The output that the future will produce on completion.
§

type IntoFuture = ResponseFuture<Invite>

Which kind of future are we turning this into?
source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more
source§

impl TryIntoRequest for CreateInvite<'_>

source§

fn try_into_request(self) -> Result<Request, Error>

Try to convert a request builder into a raw Request. Read more

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§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
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 Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.
§

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

§

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