Struct serenity::builder::CreateInvite [−][src]
Expand description
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;
#[serenity::async_trait]
impl EventHandler for Handler {
async fn message(&self, context: Context, msg: Message) {
if msg.content == "!createinvite" {
let channel = match context.cache.guild_channel(msg.channel_id).await {
Some(channel) => channel,
None => {
let _ = msg.channel_id.say(&context, "Error creating invite").await;
return;
},
};
let creation =
channel.create_invite(&context, |i| i.max_age(3600).max_uses(10)).await;
let invite = match creation {
Ok(invite) => invite,
Err(why) => {
println!("Err creating invite: {:?}", why);
if let Err(why) =
msg.channel_id.say(&context, "Error creating invite").await
{
println!("Err sending err msg: {:?}", why);
}
return;
},
};
let content = format!("Here's your invite: {}", invite.url());
let _ = msg.channel_id.say(&context, &content).await;
}
}
}
let mut client = Client::builder("token").event_handler(Handler).await?;
client.start().await?;
Tuple Fields
0: HashMap<&'static str, Value>
Implementations
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(context, |i| {
i.max_age(3600)
})
.await?;
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(context, |i| {
i.max_uses(5)
})
.await?;
Whether an invite grants a temporary membership.
Defaults to false
.
Examples
Create an invite which is temporary:
let invite = channel.create_invite(context, |i| {
i.temporary(true)
})
.await?;
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(context, |i| {
i.unique(true)
})
.await?;
The type of target for this voice channel invite.
The ID of the user whose stream to display for this invite, required if target_type
is
Stream
The user must be streaming in the channel.
The ID of the embedded application to open for this invite, required if target_type
is
EmmbeddedApplication
The application must have the EMBEDDED
flag.
When sending an invite with this value, the first user to use the invite will have to click on the URL, that will enable the buttons in the embed.
These are some of the known applications which have the flag:
betrayal: 773336526917861400
youtube: 755600276941176913
fishing: 814288819477020702
poker: 755827207812677713
chess: 832012774040141894
Trait Implementations
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 RefUnwindSafe for CreateInvite
impl Send for CreateInvite
impl Sync for CreateInvite
impl Unpin for CreateInvite
impl UnwindSafe for CreateInvite
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
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