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

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.

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.

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). See Discord Docs/Create Channel Invite.

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

Trait Implementations

Attach an audit log reason to the request. Read more

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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