Struct serenity::builder::CreateInvite [−][src]
A builder to create a RichInvite
for use via GuildChannel::create_invite
.
This is a structured and cleaner way of creating an invite, as all parameters are optional.
Examples
Create an invite with a max age of 3600 seconds and 10 max uses:
struct Handler; impl EventHandler for Handler { fn message(&self, _: Context, msg: Message) { use serenity::CACHE; if msg.content == "!createinvite" { let channel = match CACHE.read().guild_channel(msg.channel_id) { Some(channel) => channel, None => { let _ = msg.channel_id.say("Error creating invite"); return; }, }; let reader = channel.read(); let invite = match reader.create_invite(|i| i.max_age(3600).max_uses(10)) { Ok(invite) => invite, Err(why) => { println!("Err creating invite: {:?}", why); if let Err(why) = msg.channel_id.say("Error creating invite") { println!("Err sending err msg: {:?}", why); } return; }, }; drop(reader); let content = format!("Here's your invite: {}", invite.url()); let _ = msg.channel_id.say(&content); } } } let mut client = Client::new("token", Handler).unwrap(); client.start().unwrap();
Methods
impl CreateInvite
[src]
impl CreateInvite
pub fn max_age(self, max_age: u64) -> Self
[src]
pub fn max_age(self, max_age: u64) -> Self
The duration that the invite will be valid for.
Set to 0
for an invite which does not expire after an amount of time.
Defaults to 86400
, or 24 hours.
Examples
Create an invite with a max age of 3600
seconds, or 1 hour:
let invite = channel.create_invite(|i| i.max_age(3600))?;
pub fn max_uses(self, max_uses: u64) -> Self
[src]
pub fn max_uses(self, max_uses: u64) -> Self
The number of uses that the invite will be valid for.
Set to 0
for an invite which does not expire after a number of uses.
Defaults to 0
.
Examples
Create an invite with a max use limit of 5
:
let invite = channel.create_invite(|i| i.max_uses(5))?;
pub fn temporary(self, temporary: bool) -> Self
[src]
pub fn temporary(self, temporary: bool) -> Self
Whether an invite grants a temporary membership.
Defaults to false
.
Examples
Create an invite which is temporary:
let invite = channel.create_invite(|i| i.temporary(true))?;
pub fn unique(self, unique: bool) -> Self
[src]
pub fn unique(self, unique: bool) -> Self
Whether or not to try to reuse a similar invite.
Defaults to false
.
Examples
Create an invite which is unique:
let invite = channel.create_invite(|i| i.unique(true))?;
Trait Implementations
impl Clone for CreateInvite
[src]
impl Clone for CreateInvite
fn clone(&self) -> CreateInvite
[src]
fn clone(&self) -> CreateInvite
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for CreateInvite
[src]
impl Debug for CreateInvite
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Default for CreateInvite
[src]
impl Default for CreateInvite
fn default() -> CreateInvite
[src]
fn default() -> CreateInvite
Creates a builder with default values, setting validate
to null
.
Examples
Create a default CreateInvite
builder:
use serenity::builder::CreateInvite; let invite_builder = CreateInvite::default();
Auto Trait Implementations
impl Send for CreateInvite
impl Send for CreateInvite
impl Sync for CreateInvite
impl Sync for CreateInvite