code
stringlengths 40
729k
| docstring
stringlengths 22
46.3k
| func_name
stringlengths 1
97
| language
stringclasses 1
value | repo
stringlengths 6
48
| path
stringlengths 8
176
| url
stringlengths 47
228
| license
stringclasses 7
values |
|---|---|---|---|---|---|---|---|
pub fn color(mut self, color: u32) -> Self {
self.0 = self.0.and_then(|mut fields| {
if color > Self::COLOR_MAXIMUM {
return Err(RoleFieldsError {
kind: RoleFieldsErrorType::ColorNotRgb { color },
});
}
fields.color.replace(color);
Ok(fields)
});
self
}
|
Set the role color.
This must be a valid hexadecimal RGB value. `0x000000` is ignored
and doesn't count towards the final computed color in the user list.
Refer to [`Self::COLOR_MAXIMUM`] for the maximum
acceptable value.
|
color
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/builder.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/builder.rs
|
ISC
|
pub fn hoist(mut self) -> Self {
if let Ok(fields) = self.0.as_mut() {
fields.hoist = Some(true);
}
self
}
|
Show the role above other roles in the user list.
|
hoist
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/builder.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/builder.rs
|
ISC
|
pub fn id(mut self, id: Id<RoleMarker>) -> Self {
self.0 = self.0.and_then(|mut fields| {
if id == Self::ROLE_ID {
return Err(RoleFieldsError {
kind: RoleFieldsErrorType::IdInvalid,
});
}
fields.id = id;
Ok(fields)
});
self
}
|
Set the id of the role.
# Errors
Returns a [`RoleFieldsErrorType::IdInvalid`] error type if the ID is set
to 1.
|
id
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/builder.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/builder.rs
|
ISC
|
pub fn mentionable(mut self) -> Self {
if let Ok(fields) = self.0.as_mut() {
fields.mentionable = Some(true);
}
self
}
|
Allow the role to be @mentioned.
|
mentionable
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/builder.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/builder.rs
|
ISC
|
pub fn permissions(mut self, permissions: Permissions) -> Self {
if let Ok(fields) = self.0.as_mut() {
fields.permissions = Some(permissions);
}
self
}
|
Set the permissions of the role.
|
permissions
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/builder.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/builder.rs
|
ISC
|
pub fn position(mut self, position: i64) -> Self {
if let Ok(fields) = self.0.as_mut() {
fields.position = Some(position);
}
self
}
|
Set the position of the role.
|
position
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/builder.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/builder.rs
|
ISC
|
pub fn topic(mut self, topic: String) -> Self {
self.0 = self.0.and_then(|mut fields| {
if topic.len() > Self::MAX_TOPIC_LENGTH {
return Err(TextFieldsError {
kind: TextFieldsErrorType::TopicTooLong { topic },
});
}
fields.topic.replace(topic);
Ok(fields)
});
self
}
|
Set the channel's topic.
# Errors
Returns a [`TextFieldsErrorType::TopicTooLong`] error type if the topic
is too long.
|
topic
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/builder.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/builder.rs
|
ISC
|
pub(super) fn build(
mut self,
id: Id<ChannelMarker>,
) -> Result<Vec<GuildChannelFields>, CategoryFieldsError> {
let fields = self.fields?;
for channel in &mut self.channels {
match channel {
GuildChannelFields::Text(t) => t.parent_id.replace(id),
GuildChannelFields::Voice(v) => v.parent_id.replace(id),
GuildChannelFields::Category(_) => None,
};
}
self.channels.insert(
0,
GuildChannelFields::Category(CategoryFields { id, ..fields }),
);
Ok(self.channels)
}
|
Build the category fields.
# Errors
Returns a [`CategoryFieldsErrorType::NameTooShort`] error type if the
name is too short.
Returns a [`CategoryFieldsErrorType::NameTooLong`] error type if the
name is too long.
|
build
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/builder.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/builder.rs
|
ISC
|
pub fn add_text(mut self, channel: TextFields) -> Self {
if let Ok(list) = self.0.as_mut() {
list.push(GuildChannelFields::Text(channel));
}
self
}
|
Add a text channel to the builder.
|
add_text
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/builder.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/builder.rs
|
ISC
|
pub fn add_voice(mut self, channel: VoiceFields) -> Self {
if let Ok(list) = self.0.as_mut() {
list.push(GuildChannelFields::Voice(channel));
}
self
}
|
Add a voice channel to the builder.
|
add_voice
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/builder.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/builder.rs
|
ISC
|
pub fn add_category_builder(mut self, channel: CategoryFieldsBuilder) -> Self {
self.0 = self.0.and_then(|mut list| {
let last_id = list
.iter()
.rev()
.find(|c| matches!(c, GuildChannelFields::Category(_)))
.map_or(Id::new(1), GuildChannelFields::id);
let mut channels = channel.build(Id::new(last_id.get() + 1))?;
list.append(&mut channels);
Ok(list)
});
self
}
|
Add a category channel builder, and all its children to the builder.
|
add_category_builder
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/builder.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/builder.rs
|
ISC
|
pub fn afk_channel_id(mut self, afk_channel_id: Id<ChannelMarker>) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.afk_channel_id = Some(afk_channel_id);
}
self
}
|
Set the ID of the AFK voice channel.
This must be an ID specified in [`channels`].
[`channels`]: Self::channels
|
afk_channel_id
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/mod.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/mod.rs
|
ISC
|
pub fn afk_timeout(mut self, afk_timeout: AfkTimeout) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.afk_timeout = Some(afk_timeout);
}
self
}
|
Set the AFK timeout, in seconds.
|
afk_timeout
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/mod.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/mod.rs
|
ISC
|
pub fn channels(mut self, channels: Vec<GuildChannelFields>) -> Self {
self.fields = self.fields.and_then(|mut fields| {
// Error 30013
// <https://discordapp.com/developers/docs/topics/opcodes-and-status-codes#json>
if channels.len() > 500 {
return Err(CreateGuildError {
kind: CreateGuildErrorType::TooManyChannels { channels },
source: None,
});
}
fields.channels.replace(channels);
Ok(fields)
});
self
}
|
Set the channels to create with the guild.
The maximum number of channels that can be provided is 500.
# Examples
```no_run
use twilight_http::{
request::guild::create_guild::{
CategoryFieldsBuilder, GuildChannelFieldsBuilder, TextFieldsBuilder, VoiceFieldsBuilder,
},
Client,
};
# #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> {
# let client = Client::new("my token".to_owned());
let text = TextFieldsBuilder::new("text channel".to_owned()).build()?;
let voice = VoiceFieldsBuilder::new("voice channel".to_owned()).build()?;
let text2 = TextFieldsBuilder::new("other text channel".to_owned())
.topic("posting".to_owned())
.build()?;
let category = CategoryFieldsBuilder::new("category channel".to_owned())
.add_text(text2)
.add_voice(voice);
let channels = GuildChannelFieldsBuilder::new()
.add_text(text)
.add_category_builder(category)
.build()?;
let guild = client
.create_guild("guild name".to_owned())
.channels(channels)
.await?;
# Ok(()) }
```
# Errors
Returns a [`CreateGuildErrorType::TooManyChannels`] error type if the
number of channels is over 500.
|
channels
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/mod.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/mod.rs
|
ISC
|
pub fn default_message_notifications(
mut self,
default_message_notifications: DefaultMessageNotificationLevel,
) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.default_message_notifications = Some(default_message_notifications);
}
self
}
|
Set the default message notification level. See
[Discord Docs/Create Guild].
[Discord Docs/Create Guild]: https://discord.com/developers/docs/resources/guild#create-guild
|
default_message_notifications
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/mod.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/mod.rs
|
ISC
|
pub fn explicit_content_filter(
mut self,
explicit_content_filter: ExplicitContentFilter,
) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.explicit_content_filter = Some(explicit_content_filter);
}
self
}
|
Set the explicit content filter level.
|
explicit_content_filter
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/mod.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/mod.rs
|
ISC
|
pub fn icon(mut self, icon: &'a str) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.icon.replace(icon);
}
self
}
|
Set the icon.
This must be a Data URI, in the form of
`data:image/{type};base64,{data}` where `{type}` is the image MIME type
and `{data}` is the base64-encoded image. See [Discord Docs/Image Data].
[Discord Docs/Image Data]: https://discord.com/developers/docs/reference#image-data
|
icon
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/mod.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/mod.rs
|
ISC
|
pub fn override_everyone(mut self, everyone: RoleFields) -> Self {
if let Ok(fields) = self.fields.as_mut() {
if let Some(roles) = fields.roles.as_mut() {
roles.remove(0);
roles.insert(0, everyone);
} else {
fields.roles.replace(vec![everyone]);
}
}
self
}
|
Override the everyone role of the guild.
If there are not yet roles set with [`roles`], this will create a role override in the
first position. Discord understands the first role in the list to override @everyone.
If there are roles, this replaces the first role in the position.
[`roles`]: Self::roles
|
override_everyone
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/mod.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/mod.rs
|
ISC
|
pub fn system_channel_id(mut self, system_channel_id: Id<ChannelMarker>) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.system_channel_id = Some(system_channel_id);
}
self
}
|
Set the channel where system messages will be posted.
This must be an ID specified in [`channels`].
[`channels`]: Self::channels
|
system_channel_id
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/create_guild/mod.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/create_guild/mod.rs
|
ISC
|
pub const fn roles(mut self, roles: &'a [Id<RoleMarker>]) -> Self {
self.fields.roles = Some(roles);
self
}
|
Whitelist roles for this emoji.
See [Discord Docs/Emoji Object].
[Discord Docs/Emoji Object]: https://discord.com/developers/docs/resources/emoji#emoji-object-emoji-structure
|
roles
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/emoji/create_emoji.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/emoji/create_emoji.rs
|
ISC
|
pub const fn name(mut self, name: &'a str) -> Self {
self.fields.name = Some(name);
self
}
|
Change the name of the emoji.
|
name
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/emoji/update_emoji.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/emoji/update_emoji.rs
|
ISC
|
pub const fn roles(mut self, roles: &'a [Id<RoleMarker>]) -> Self {
self.fields.roles = Some(roles);
self
}
|
Change the roles that the emoji is whitelisted to.
|
roles
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/emoji/update_emoji.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/emoji/update_emoji.rs
|
ISC
|
pub fn deaf(mut self, deaf: bool) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.deaf = Some(deaf);
}
self
}
|
Whether the new member will be unable to hear audio when connected to a
voice channel.
|
deaf
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/member/add_guild_member.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/member/add_guild_member.rs
|
ISC
|
pub fn mute(mut self, mute: bool) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.mute = Some(mute);
}
self
}
|
Whether the new member will be unable to speak in voice channels.
|
mute
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/member/add_guild_member.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/member/add_guild_member.rs
|
ISC
|
pub fn nick(mut self, nick: &'a str) -> Self {
self.fields = self.fields.and_then(|mut fields| {
validate_nickname(nick)?;
fields.nick.replace(nick);
Ok(fields)
});
self
}
|
Set the user's initial nickname.
The minimum length is 1 UTF-16 character and the maximum is 32 UTF-16
characters.
# Errors
Returns an error of type [`Nickname`] if the nickname length is too
short or too long.
[`Nickname`]: twilight_validate::request::ValidationErrorType::Nickname
|
nick
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/member/add_guild_member.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/member/add_guild_member.rs
|
ISC
|
pub fn roles(mut self, roles: &'a [Id<RoleMarker>]) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.roles = Some(roles);
}
self
}
|
List of roles to assign the new member.
|
roles
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/member/add_guild_member.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/member/add_guild_member.rs
|
ISC
|
pub fn after(mut self, after: Id<UserMarker>) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.after = Some(after);
}
self
}
|
Sets the user ID to get members after.
|
after
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/member/get_guild_members.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/member/get_guild_members.rs
|
ISC
|
pub fn channel_id(mut self, channel_id: Option<Id<ChannelMarker>>) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.channel_id = Some(Nullable(channel_id));
}
self
}
|
Move the member to a different voice channel.
|
channel_id
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/member/update_guild_member.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/member/update_guild_member.rs
|
ISC
|
pub fn communication_disabled_until(mut self, timestamp: Option<Timestamp>) -> Self {
self.fields = self.fields.and_then(|mut fields| {
if let Some(timestamp) = timestamp {
validate_communication_disabled_until(timestamp)?;
}
fields.communication_disabled_until = Some(Nullable(timestamp));
Ok(fields)
});
self
}
|
Set the member's [Guild Timeout].
The timestamp indicates when the user will be able to communicate again.
It can be up to 28 days in the future. Set to [`None`] to remove the
timeout. Requires the [`MODERATE_MEMBERS`] permission. If this is set,
and if the target member is an administrator or the owner of the guild,
the response status code will be 403.
# Errors
Returns an error of type [`CommunicationDisabledUntil`] if the expiry
timestamp is more than 28 days from the current time.
[Guild Timeout]: https://support.discord.com/hc/en-us/articles/4413305239191-Time-Out-FAQ
[`CommunicationDisabledUntil`]: twilight_validate::request::ValidationErrorType::CommunicationDisabledUntil
[`MODERATE_MEMBERS`]: twilight_model::guild::Permissions::MODERATE_MEMBERS
|
communication_disabled_until
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/member/update_guild_member.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/member/update_guild_member.rs
|
ISC
|
pub fn deaf(mut self, deaf: bool) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.deaf = Some(deaf);
}
self
}
|
If true, restrict the member's ability to hear sound from a voice channel.
|
deaf
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/member/update_guild_member.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/member/update_guild_member.rs
|
ISC
|
pub fn mute(mut self, mute: bool) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.mute = Some(mute);
}
self
}
|
If true, restrict the member's ability to speak in a voice channel.
|
mute
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/member/update_guild_member.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/member/update_guild_member.rs
|
ISC
|
pub fn nick(mut self, nick: Option<&'a str>) -> Self {
self.fields = self.fields.and_then(|mut fields| {
if let Some(nick) = nick {
validate_nickname(nick)?;
}
fields.nick = Some(Nullable(nick));
Ok(fields)
});
self
}
|
Set the nickname.
The minimum length is 1 UTF-16 character and the maximum is 32 UTF-16 characters.
# Errors
Returns an error of type [`Nickname`] if the nickname length is too
short or too long.
[`Nickname`]: twilight_validate::request::ValidationErrorType::Nickname
|
nick
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/member/update_guild_member.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/member/update_guild_member.rs
|
ISC
|
pub fn roles(mut self, roles: &'a [Id<RoleMarker>]) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.roles = Some(roles);
}
self
}
|
Set the new list of roles for a member.
|
roles
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/member/update_guild_member.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/member/update_guild_member.rs
|
ISC
|
pub const fn color(mut self, color: u32) -> Self {
self.fields.color = Some(color);
self
}
|
Set the role color.
This must be a valid hexadecimal RGB value. `0x000000` is ignored and
doesn't count towards the final computed color in the user list. Refer
to [`COLOR_MAXIMUM`] for the maximum acceptable value.
[`COLOR_MAXIMUM`]: twilight_validate::embed::COLOR_MAXIMUM
|
color
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/role/create_role.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/role/create_role.rs
|
ISC
|
pub const fn hoist(mut self, hoist: bool) -> Self {
self.fields.hoist = Some(hoist);
self
}
|
If true, display the role in the members list.
|
hoist
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/role/create_role.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/role/create_role.rs
|
ISC
|
pub const fn icon(mut self, icon: &'a [u8]) -> Self {
self.fields.icon = Some(icon);
self
}
|
Set the icon of the role.
Only works if the guild has the `ROLE_ICONS` feature.
See [Discord Docs/Image Data].
[Discord Docs/Image Data]: https://discord.com/developers/docs/reference#image-data
|
icon
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/role/create_role.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/role/create_role.rs
|
ISC
|
pub const fn mentionable(mut self, mentionable: bool) -> Self {
self.fields.mentionable = Some(mentionable);
self
}
|
If true, the role can be @mentioned (pinged) in chat.
|
mentionable
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/role/create_role.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/role/create_role.rs
|
ISC
|
pub const fn name(mut self, name: &'a str) -> Self {
self.fields.name = Some(name);
self
}
|
Set the name of the role.
If none is specified, Discord sets this to `New Role`.
|
name
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/role/create_role.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/role/create_role.rs
|
ISC
|
pub const fn permissions(mut self, permissions: Permissions) -> Self {
self.fields.permissions = Some(permissions);
self
}
|
Set the allowed permissions of this role.
|
permissions
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/role/create_role.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/role/create_role.rs
|
ISC
|
pub const fn unicode_emoji(mut self, unicode_emoji: &'a str) -> Self {
self.fields.unicode_emoji = Some(unicode_emoji);
self
}
|
Set the unicode emoji of a role.
|
unicode_emoji
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/role/create_role.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/role/create_role.rs
|
ISC
|
pub const fn color(mut self, color: Option<u32>) -> Self {
self.fields.color = Some(Nullable(color));
self
}
|
Set the role color.
This must be a valid hexadecimal RGB value. `0x000000` is ignored and
doesn't count towards the final computed color in the user list. Refer
to [`COLOR_MAXIMUM`] for the maximum acceptable value.
[`COLOR_MAXIMUM`]: twilight_validate::embed::COLOR_MAXIMUM
|
color
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/role/update_role.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/role/update_role.rs
|
ISC
|
pub const fn hoist(mut self, hoist: bool) -> Self {
self.fields.hoist = Some(hoist);
self
}
|
If true, display the role in the members list.
|
hoist
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/role/update_role.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/role/update_role.rs
|
ISC
|
pub const fn icon(mut self, icon: Option<&'a str>) -> Self {
self.fields.icon = Some(Nullable(icon));
self
}
|
Set the icon of the role.
Only works if the guild has the `ROLE_ICONS` feature.
See [Discord Docs/Image Data].
[Discord Docs/Image Data]: https://discord.com/developers/docs/reference#image-data
# Editing
Pass [`None`] to clear the existing icon.
**Warning**: If the existing unicode emoji isn't cleared when setting the icon, it might
cause incorrect behavior.
# Examples
Sets a role icon. The unicode emoji should always be cleared to ensure the icon can be
set correctly.
```no_run
# #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> {
use twilight_http::Client;
use twilight_model::id::Id;
let client = Client::new("token".to_owned());
let guild_id = Id::new(1);
let role_id = Id::new(1);
let icon = "data:image/png;base64,BASE64_ENCODED_PNG_IMAGE_DATA";
client
.update_role(guild_id, role_id)
.icon(Some(icon))
.unicode_emoji(None)
.await?;
# Ok(()) }
```
|
icon
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/role/update_role.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/role/update_role.rs
|
ISC
|
pub const fn mentionable(mut self, mentionable: bool) -> Self {
self.fields.mentionable = Some(mentionable);
self
}
|
If true, the role can be @mentioned (pinged) in chat.
|
mentionable
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/role/update_role.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/role/update_role.rs
|
ISC
|
pub const fn name(mut self, name: Option<&'a str>) -> Self {
self.fields.name = Some(Nullable(name));
self
}
|
Set the name of the role.
|
name
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/role/update_role.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/role/update_role.rs
|
ISC
|
pub const fn permissions(mut self, permissions: Permissions) -> Self {
self.fields.permissions = Some(permissions);
self
}
|
Set the allowed permissions of this role.
|
permissions
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/role/update_role.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/role/update_role.rs
|
ISC
|
pub fn description(mut self, description: &'a str) -> Self {
self.fields = self.fields.and_then(|mut fields| {
validate_description(description)?;
fields.description = Some(description);
Ok(fields)
});
self
}
|
Set the sticker's description.
# Errors
Returns an error of type [`DescriptionInvalid`] if the length is invalid.
[`DescriptionInvalid`]: twilight_validate::sticker::StickerValidationErrorType::DescriptionInvalid
|
description
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/sticker/update_guild_sticker.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/sticker/update_guild_sticker.rs
|
ISC
|
pub fn name(mut self, name: &'a str) -> Self {
self.fields = self.fields.and_then(|mut fields| {
validate_name(name)?;
fields.name = Some(name);
Ok(fields)
});
self
}
|
Set the sticker's name.
# Errors
Returns an error of type [`NameInvalid`] if the length is invalid.
[`NameInvalid`]: twilight_validate::sticker::StickerValidationErrorType::NameInvalid
|
name
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/sticker/update_guild_sticker.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/sticker/update_guild_sticker.rs
|
ISC
|
pub fn tags(mut self, tags: &'a str) -> Self {
self.fields = self.fields.and_then(|mut fields| {
validate_tags(tags)?;
fields.tags = Some(tags);
Ok(fields)
});
self
}
|
Set the sticker's tags.
# Errors
Returns an error of type [`TagsInvalid`] if the length is invalid.
[`TagsInvalid`]: twilight_validate::sticker::StickerValidationErrorType::TagsInvalid
|
tags
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/sticker/update_guild_sticker.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/sticker/update_guild_sticker.rs
|
ISC
|
pub const fn channel_id(mut self, channel_id: Id<ChannelMarker>) -> Self {
self.fields.channel_id = Some(channel_id);
self
}
|
Specify the ID of the stage channel which the user is currently connected to.
# Caveats
- `channel_id` must currently point to a stage channel.
- User must already be connected to this stage channel.
|
channel_id
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/user/update_current_user_voice_state.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/user/update_current_user_voice_state.rs
|
ISC
|
pub const fn request_to_speak_timestamp(mut self, request_to_speak_timestamp: &'a str) -> Self {
if request_to_speak_timestamp.is_empty() {
self.fields.request_to_speak_timestamp = Some(Nullable(None));
} else {
self.fields.request_to_speak_timestamp =
Some(Nullable(Some(request_to_speak_timestamp)));
}
self
}
|
Set the user's request to speak.
Set to an empty string to remove an already-present request.
# Caveats
- You are able to set `request_to_speak_timestamp` to any present or
future time.
|
request_to_speak_timestamp
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/user/update_current_user_voice_state.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/user/update_current_user_voice_state.rs
|
ISC
|
pub const fn suppress(mut self) -> Self {
self.fields.suppress = Some(true);
self
}
|
Toggle the user's suppress state.
# Caveats
- You must have the `MUTE_MEMBERS` permission to unsuppress yourself.
- You can always suppress yourself.
|
suppress
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/user/update_current_user_voice_state.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/user/update_current_user_voice_state.rs
|
ISC
|
pub const fn suppress(mut self) -> Self {
self.fields.suppress = Some(true);
self
}
|
Toggle the user's suppress state.
# Caveats
- You must have the [`MUTE_MEMBERS`] permission to use this method.
- When unsuppressed, non-bot users will have their
`request_to_speak_timestamp` set to the current time. Bot users will
not.
- When suppressed, the user will have their `request_to_speak_timestamp`
removed.
[`MUTE_MEMBERS`]: twilight_model::guild::Permissions::MUTE_MEMBERS
|
suppress
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/guild/user/update_user_voice_state.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/guild/user/update_user_voice_state.rs
|
ISC
|
pub fn after(mut self, after: Id<UserMarker>) -> Self {
self.fields.after.replace(after);
self
}
|
Set the user ID to get voters after.
|
after
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/poll/get_answer_voters.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/poll/get_answer_voters.rs
|
ISC
|
pub const fn with_user_count(mut self, with_user_count: bool) -> Self {
self.with_user_count = with_user_count;
self
}
|
Set whether to include the number of subscribed users.
|
with_user_count
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/get_guild_scheduled_event.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/get_guild_scheduled_event.rs
|
ISC
|
pub const fn with_user_count(mut self, with_user_count: bool) -> Self {
self.with_user_count = with_user_count;
self
}
|
Set whether to include the number of subscribed users.
|
with_user_count
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/get_guild_scheduled_events.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/get_guild_scheduled_events.rs
|
ISC
|
pub fn after(mut self, after: Id<UserMarker>) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.after = Some(after);
}
self
}
|
Get users after this user ID.
This is incompatible with [`before`], and has no effect if [`before`] is
also set.
[`before`]: Self::before
|
after
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/get_guild_scheduled_event_users.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/get_guild_scheduled_event_users.rs
|
ISC
|
pub fn before(mut self, before: Id<UserMarker>) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.before = Some(before);
}
self
}
|
Get users before this user ID.
This is incompatible with [`after`].
[`after`]: Self::after
|
before
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/get_guild_scheduled_event_users.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/get_guild_scheduled_event_users.rs
|
ISC
|
pub fn with_member(mut self, with_member: bool) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.with_member = Some(with_member);
}
self
}
|
Set whether to return member objects with each user.
|
with_member
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/get_guild_scheduled_event_users.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/get_guild_scheduled_event_users.rs
|
ISC
|
pub fn channel_id(mut self, channel_id: Id<ChannelMarker>) -> Self {
if let Ok(fields) = self.fields.as_mut() {
if fields.entity_type != Some(EntityType::External) {
fields.channel_id = Some(Nullable(Some(channel_id)));
}
}
self
}
|
Set the channel ID.
If `entity_type` is already [`EntityType::External`], this has no
effect.
|
channel_id
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
ISC
|
pub fn description(mut self, description: Option<&'a str>) -> Self {
self.fields = self.fields.and_then(|mut fields| {
if let Some(description) = description {
validate_scheduled_event_description(description)?;
}
fields.description = Some(Nullable(description));
Ok(fields)
});
self
}
|
Set the description of the event.
Must be between 1 and 1000 characters in length.
# Errors
Returns an error of type [`ScheduledEventDescription`] if the
description is invalid.
[`ScheduledEventDescription`]: twilight_validate::request::ValidationErrorType::ScheduledEventDescription
|
description
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
ISC
|
pub fn entity_type(mut self, entity_type: EntityType) -> Self {
self.fields = self.fields.map(|mut fields| {
if entity_type == EntityType::External {
fields.channel_id = None;
}
fields.entity_type = Some(entity_type);
fields
});
self
}
|
Set the [`EntityType`] of the scheduled event.
See the struct-level documentation for information about required fields
for each type.
|
entity_type
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
ISC
|
pub fn image(mut self, image: Option<&'a str>) -> Self {
self.fields = self.fields.map(|mut fields| {
fields.image = Some(Nullable(image));
fields
});
self
}
|
Set the cover image of the event.
Pass [`None`] to clear the image.
This must be a Data URI, in the form of
`data:image/{type};base64,{data}` where `{type}` is the image MIME type
and `{data}` is the base64-encoded image. See [Discord Docs/Image Data].
[Discord Docs/Image Data]: https://discord.com/developers/docs/reference#image-data
|
image
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
ISC
|
pub fn location(mut self, location: Option<&'a str>) -> Self {
self.fields = self.fields.map(|mut fields| {
fields.entity_metadata = Some(EntityMetadataFields { location });
fields
});
self
}
|
Set the location of the external scheduled event.
This only functions if the event's [`EntityType`] is [`External`].
[`External`]: EntityType::External
|
location
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
ISC
|
pub fn name(mut self, name: &'a str) -> Self {
self.fields = self.fields.and_then(|mut fields| {
validate_scheduled_event_name(name)?;
fields.name = Some(name);
Ok(fields)
});
self
}
|
Set the name of the event.
Must be between 1 and 100 characters in length.
# Errors
Returns an error of type [`ScheduledEventName`] if the name is invalid.
[`ScheduledEventName`]: twilight_validate::request::ValidationErrorType::ScheduledEventName
|
name
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
ISC
|
pub fn scheduled_end_time(mut self, scheduled_end_time: Option<&'a Timestamp>) -> Self {
self.fields = self.fields.map(|mut fields| {
fields.scheduled_end_time = Some(Nullable(scheduled_end_time));
fields
});
self
}
|
Set the scheduled end time of the event.
Required for external events.
|
scheduled_end_time
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
ISC
|
pub fn scheduled_start_time(mut self, scheduled_start_time: &'a Timestamp) -> Self {
self.fields = self.fields.map(|mut fields| {
fields.scheduled_start_time = Some(scheduled_start_time);
fields
});
self
}
|
Set the scheduled start time of the event.
|
scheduled_start_time
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
ISC
|
pub fn status(mut self, status: Status) -> Self {
self.fields = self.fields.map(|mut fields| {
fields.status = Some(status);
fields
});
self
}
|
Set the status of the event.
If an event is currently [`Scheduled`], it can only be set to [`Active`]
or [`Cancelled`]. If it is currently [`Active`], it can only be set to
[`Completed`]. Otherwise, the status can not be updated.
[`Active`]: Status::Active
[`Cancelled`]: Status::Cancelled
[`Completed`]: Status::Completed
[`Scheduled`]: Status::Scheduled
|
status
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/update_guild_scheduled_event.rs
|
ISC
|
pub fn description(mut self, description: &'a str) -> Self {
self.0.fields = self.0.fields.and_then(|mut fields| {
validate_scheduled_event_description(description)?;
fields.description.replace(description);
Ok(fields)
});
self
}
|
Set the description of the event.
Must be between 1 and 1000 characters in length.
# Errors
Returns an error of type [`ScheduledEventDescription`] if the
description is invalid.
[`ScheduledEventDescription`]: twilight_validate::request::ValidationErrorType::ScheduledEventDescription
|
description
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/create_guild_scheduled_event/external.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/create_guild_scheduled_event/external.rs
|
ISC
|
pub fn image(mut self, image: &'a str) -> Self {
self.0.fields = self.0.fields.map(|mut fields| {
fields.image = Some(image);
fields
});
self
}
|
Set the cover image of the event.
This must be a Data URI, in the form of
`data:image/{type};base64,{data}` where `{type}` is the image MIME type
and `{data}` is the base64-encoded image. See [Discord Docs/Image Data].
[Discord Docs/Image Data]: https://discord.com/developers/docs/reference#image-data
|
image
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/create_guild_scheduled_event/external.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/create_guild_scheduled_event/external.rs
|
ISC
|
pub fn external(
mut self,
name: &'a str,
location: &'a str,
scheduled_start_time: &'a Timestamp,
scheduled_end_time: &'a Timestamp,
) -> CreateGuildExternalScheduledEvent<'a> {
self.fields = self.fields.and_then(|mut fields| {
validate_scheduled_event_name(name)?;
fields.name.replace(name);
Ok(fields)
});
CreateGuildExternalScheduledEvent::new(
self,
name,
location,
scheduled_start_time,
scheduled_end_time,
)
}
|
Create an external scheduled event in a guild.
The name must be between 1 and 100 characters in length.
# Errors
Returns an error of type [`ScheduledEventName`] if the name is invalid.
[`ScheduledEventName`]: twilight_validate::request::ValidationErrorType::ScheduledEventName
|
external
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/create_guild_scheduled_event/mod.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/create_guild_scheduled_event/mod.rs
|
ISC
|
pub fn stage_instance(
mut self,
channel_id: Id<ChannelMarker>,
name: &'a str,
scheduled_start_time: &'a Timestamp,
) -> CreateGuildStageInstanceScheduledEvent<'a> {
self.fields = self.fields.and_then(|mut fields| {
validate_scheduled_event_name(name)?;
fields.name.replace(name);
Ok(fields)
});
CreateGuildStageInstanceScheduledEvent::new(self, channel_id, name, scheduled_start_time)
}
|
Create a stage instance scheduled event in a guild.
The name must be between 1 and 100 characters in length.
# Errors
Returns an error of type [`ScheduledEventName`] if the name is invalid.
[`ScheduledEventName`]: twilight_validate::request::ValidationErrorType::ScheduledEventName
|
stage_instance
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/create_guild_scheduled_event/mod.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/create_guild_scheduled_event/mod.rs
|
ISC
|
pub fn voice(
mut self,
channel_id: Id<ChannelMarker>,
name: &'a str,
scheduled_start_time: &'a Timestamp,
) -> CreateGuildVoiceScheduledEvent<'a> {
self.fields = self.fields.and_then(|mut fields| {
validate_scheduled_event_name(name)?;
fields.name.replace(name);
Ok(fields)
});
CreateGuildVoiceScheduledEvent::new(self, channel_id, name, scheduled_start_time)
}
|
Create a voice channel scheduled event in a guild.
The name must be between 1 and 100 characters in length.
# Errors
Returns an error of type [`ScheduledEventName`] if the name is invalid.
[`ScheduledEventName`]: twilight_validate::request::ValidationErrorType::ScheduledEventName
|
voice
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/create_guild_scheduled_event/mod.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/create_guild_scheduled_event/mod.rs
|
ISC
|
pub fn description(mut self, description: &'a str) -> Self {
self.0.fields = self.0.fields.and_then(|mut fields| {
validate_scheduled_event_description(description)?;
fields.description.replace(description);
Ok(fields)
});
self
}
|
Set the description of the event.
Must be between 1 and 1000 characters in length.
# Errors
Returns an error of type [`ScheduledEventDescription`] if the
description is invalid.
[`ScheduledEventDescription`]: twilight_validate::request::ValidationErrorType::ScheduledEventDescription
|
description
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/create_guild_scheduled_event/stage_instance.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/create_guild_scheduled_event/stage_instance.rs
|
ISC
|
pub fn image(mut self, image: &'a str) -> Self {
self.0.fields = self.0.fields.map(|mut fields| {
fields.image = Some(image);
fields
});
self
}
|
Set the cover image of the event.
This must be a Data URI, in the form of
`data:image/{type};base64,{data}` where `{type}` is the image MIME type
and `{data}` is the base64-encoded image. See [Discord Docs/Image Data].
[Discord Docs/Image Data]: https://discord.com/developers/docs/reference#image-data
|
image
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/create_guild_scheduled_event/stage_instance.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/create_guild_scheduled_event/stage_instance.rs
|
ISC
|
pub fn scheduled_end_time(mut self, scheduled_end_time: &'a Timestamp) -> Self {
self.0.fields = self.0.fields.map(|mut fields| {
fields.scheduled_end_time = Some(scheduled_end_time);
fields
});
self
}
|
Set the scheduled end time of the event.
This is not a required field for stage instance events.
|
scheduled_end_time
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/create_guild_scheduled_event/stage_instance.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/create_guild_scheduled_event/stage_instance.rs
|
ISC
|
pub fn description(mut self, description: &'a str) -> Self {
self.0.fields = self.0.fields.and_then(|mut fields| {
validate_scheduled_event_description(description)?;
fields.description.replace(description);
Ok(fields)
});
self
}
|
Set the description of the event.
Must be between 1 and 1000 characters in length.
# Errors
Returns an error of type [`ScheduledEventDescription`] if the
description is invalid.
[`ScheduledEventDescription`]: twilight_validate::request::ValidationErrorType::ScheduledEventDescription
|
description
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/create_guild_scheduled_event/voice.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/create_guild_scheduled_event/voice.rs
|
ISC
|
pub fn image(mut self, image: &'a str) -> Self {
self.0.fields = self.0.fields.map(|mut fields| {
fields.image = Some(image);
fields
});
self
}
|
Set the cover image of the event.
This must be a Data URI, in the form of
`data:image/{type};base64,{data}` where `{type}` is the image MIME type
and `{data}` is the base64-encoded image. See [Discord Docs/Image Data].
[Discord Docs/Image Data]: https://discord.com/developers/docs/reference#image-data
|
image
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/create_guild_scheduled_event/voice.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/create_guild_scheduled_event/voice.rs
|
ISC
|
pub fn scheduled_end_time(mut self, scheduled_end_time: &'a Timestamp) -> Self {
self.0.fields = self.0.fields.map(|mut fields| {
fields.scheduled_end_time = Some(scheduled_end_time);
fields
});
self
}
|
Set the scheduled end time of the event.
This is not a required field for voice channel events.
|
scheduled_end_time
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/scheduled_event/create_guild_scheduled_event/voice.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/scheduled_event/create_guild_scheduled_event/voice.rs
|
ISC
|
pub fn icon(mut self, icon: &'a str) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.icon = Some(icon);
}
self
}
|
Set the icon.
This must be a Data URI, in the form of
`data:image/{type};base64,{data}` where `{type}` is the image MIME type
and `{data}` is the base64-encoded image. See [Discord Docs/Image Data].
[Discord Docs/Image Data]: https://discord.com/developers/docs/reference#image-data
|
icon
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/template/create_guild_from_template.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/template/create_guild_from_template.rs
|
ISC
|
pub fn description(mut self, description: &'a str) -> Self {
self.fields = self.fields.and_then(|mut fields| {
validate_template_description(description)?;
fields.description.replace(description);
Ok(fields)
});
self
}
|
Set the template's description.
This must be less than or equal to 120 characters in length.
# Errors
Returns an error of type [`TemplateDescription`] if the name length is
too short or too long.
[`TemplateDescription`]: twilight_validate::request::ValidationErrorType::TemplateDescription
|
description
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/template/create_template.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/template/create_template.rs
|
ISC
|
pub fn description(mut self, description: &'a str) -> Self {
self.fields = self.fields.and_then(|mut fields| {
validate_template_description(description)?;
fields.description.replace(description);
Ok(fields)
});
self
}
|
Set the description.
This must be at most 120 characters in length.
# Errors
Returns an error of type [`TemplateDescription`] if the name length is
too short or too long.
[`TemplateDescription`]: twilight_validate::request::ValidationErrorType::TemplateDescription
|
description
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/template/update_template.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/template/update_template.rs
|
ISC
|
pub fn name(mut self, name: &'a str) -> Self {
self.fields = self.fields.and_then(|mut fields| {
validate_template_name(name)?;
fields.name.replace(name);
Ok(fields)
});
self
}
|
Set the name.
This must be at least 1, and at most 100 characters in length.
# Errors
Returns an error of type [`TemplateName`] if the name length is too
short or too long.
[`TemplateName`]: twilight_validate::request::ValidationErrorType::TemplateName
|
name
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/template/update_template.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/template/update_template.rs
|
ISC
|
pub fn after(mut self, guild_id: Id<GuildMarker>) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.after = Some(guild_id);
}
self
}
|
Get guilds after this guild id.
|
after
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/user/get_current_user_guilds.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/user/get_current_user_guilds.rs
|
ISC
|
pub fn before(mut self, guild_id: Id<GuildMarker>) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.before = Some(guild_id);
}
self
}
|
Get guilds before this guild id.
|
before
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/user/get_current_user_guilds.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/user/get_current_user_guilds.rs
|
ISC
|
pub fn limit(mut self, limit: u16) -> Self {
self.fields = self.fields.and_then(|mut fields| {
validate_get_current_user_guilds_limit(limit)?;
fields.limit = Some(limit);
Ok(fields)
});
self
}
|
Set the maximum number of guilds to retrieve.
The minimum is 1 and the maximum is 200. See
[Discord Docs/Get Current User Guilds].
# Errors
Returns an error of type [`GetCurrentUserGuilds`] if the name length is
too short or too long.
[`GetCurrentUserGuilds`]: twilight_validate::request::ValidationErrorType::GetCurrentUserGuilds
[Discord Docs/Get Current User Guilds]: https://discordapp.com/developers/docs/resources/user#get-current-user-guilds-query-string-params
|
limit
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/user/get_current_user_guilds.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/user/get_current_user_guilds.rs
|
ISC
|
pub fn avatar(mut self, avatar: Option<&'a str>) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.avatar = Some(Nullable(avatar));
}
self
}
|
Set the user's avatar.
This must be a Data URI, in the form of
`data:image/{type};base64,{data}` where `{type}` is the image MIME type
and `{data}` is the base64-encoded image. See [Discord Docs/Image Data].
[Discord Docs/Image Data]: https://discord.com/developers/docs/reference#image-data
|
avatar
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/user/update_current_user.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/user/update_current_user.rs
|
ISC
|
pub fn banner(mut self, banner: Option<&'a str>) -> Self {
if let Ok(fields) = self.fields.as_mut() {
fields.banner = Some(Nullable(banner));
}
self
}
|
Set the user's banner.
This must be a Data URI, in the form of
`data:image/{type};base64,{data}` where `{type}` is the image MIME type
and `{data}` is the base64-encoded image. See [Discord Docs/Image Data].
[Discord Docs/Image Data]: https://discord.com/developers/docs/reference#image-data
|
banner
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/user/update_current_user.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/user/update_current_user.rs
|
ISC
|
pub fn username(mut self, username: &'a str) -> Self {
self.fields = self.fields.and_then(|mut fields| {
validate_username(username)?;
fields.username.replace(username);
Ok(fields)
});
self
}
|
Set the username.
The minimum length is 1 UTF-16 character and the maximum is 32 UTF-16 characters.
# Errors
Returns an error of type [`Username`] if the username length is too
short or too long.
[`Username`]: twilight_validate::request::ValidationErrorType::Username
|
username
|
rust
|
twilight-rs/twilight
|
twilight-http/src/request/user/update_current_user.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/user/update_current_user.rs
|
ISC
|
pub fn bytes(self) -> BytesFuture {
#[cfg(feature = "decompression")]
let compressed = self
.inner
.headers()
.get(http::header::CONTENT_ENCODING)
.is_some();
let body = self.inner.into_body();
let fut = async move {
{
#[cfg(feature = "decompression")]
if compressed {
return decompress(body).await;
}
Ok(body
.collect()
.await
.map_err(|source| DeserializeBodyError {
kind: DeserializeBodyErrorType::Chunking,
source: Some(Box::new(source)),
})?
.to_bytes())
}
};
BytesFuture {
inner: Box::pin(fut),
}
}
|
Consume the response and accumulate the chunked body into bytes.
For a textual representation of the response body [`text`] should be
preferred.
# Examples
Count the number of bytes in a response body:
```no_run
# #[tokio::main]
# async fn main() -> Result<(), Box<dyn std::error::Error>> {
# let user_id = twilight_model::id::Id::new(1);
use std::env;
use twilight_http::Client;
let client = Client::new(env::var("DISCORD_TOKEN")?);
let response = client.user(user_id).await?;
let bytes = response.bytes().await?;
println!("size of body: {}", bytes.len());
# Ok(()) }
```
# Errors
Returns a [`DeserializeBodyErrorType::Chunking`] error type if the
response body could not be entirely read.
[`text`]: Self::text
|
bytes
|
rust
|
twilight-rs/twilight
|
twilight-http/src/response/mod.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/response/mod.rs
|
ISC
|
pub(crate) const fn new(code: u16) -> Self {
// We don't need to do any checking that the status code is valid since
// the value always comes from `hyper`'s status code implementation.
Self(code)
}
|
Create a new status code from a raw status code.
|
new
|
rust
|
twilight-rs/twilight
|
twilight-http/src/response/status_code.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/response/status_code.rs
|
ISC
|
const fn in_range(self, min: u16, max: u16) -> bool {
self.0 >= min && self.0 < max
}
|
Whether the status code is within a range.
The range is defined as `[min, max)`.
|
in_range
|
rust
|
twilight-rs/twilight
|
twilight-http/src/response/status_code.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/response/status_code.rs
|
ISC
|
pub(super) fn missing(name: HeaderName) -> Self {
Self {
kind: HeaderParsingErrorType::Missing { name },
source: None,
}
}
|
Create a new error because a header is missing in the response.
|
missing
|
rust
|
twilight-rs/twilight
|
twilight-http-ratelimiting/src/headers.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http-ratelimiting/src/headers.rs
|
ISC
|
pub(super) fn not_utf8(name: HeaderName, value: Vec<u8>, source: Utf8Error) -> Self {
Self {
kind: HeaderParsingErrorType::NotUtf8 { name, value },
source: Some(Box::new(source)),
}
}
|
Create a new error because a header is not valid UTF-8.
|
not_utf8
|
rust
|
twilight-rs/twilight
|
twilight-http-ratelimiting/src/headers.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http-ratelimiting/src/headers.rs
|
ISC
|
const fn name(self) -> &'static str {
match self {
Self::Bool => "bool",
Self::Float => "float",
Self::Integer => "integer",
Self::String => "string",
}
}
|
Name of the type of header.
|
name
|
rust
|
twilight-rs/twilight
|
twilight-http-ratelimiting/src/headers.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http-ratelimiting/src/headers.rs
|
ISC
|
fn header_float(name: HeaderName, value: &[u8]) -> Result<f64, HeaderParsingError> {
let text = header_str(name, value)?;
let end = text.parse().map_err(|source| HeaderParsingError {
kind: HeaderParsingErrorType::Parsing {
kind: HeaderType::Float,
name,
value: text.to_owned(),
},
source: Some(Box::new(source)),
})?;
Ok(end)
}
|
Parse a value expected to be a float.
|
header_float
|
rust
|
twilight-rs/twilight
|
twilight-http-ratelimiting/src/headers.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http-ratelimiting/src/headers.rs
|
ISC
|
fn header_int(name: HeaderName, value: &[u8]) -> Result<u64, HeaderParsingError> {
let text = header_str(name, value)?;
let end = text.parse().map_err(|source| HeaderParsingError {
kind: HeaderParsingErrorType::Parsing {
kind: HeaderType::Integer,
name,
value: text.to_owned(),
},
source: Some(Box::new(source)),
})?;
Ok(end)
}
|
Parse a value expected to be an integer.
|
header_int
|
rust
|
twilight-rs/twilight
|
twilight-http-ratelimiting/src/headers.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http-ratelimiting/src/headers.rs
|
ISC
|
fn header_str(name: HeaderName, value: &[u8]) -> Result<&str, HeaderParsingError> {
let text = str::from_utf8(value)
.map_err(|source| HeaderParsingError::not_utf8(name, value.to_owned(), source))?;
Ok(text)
}
|
Parse a value expected to be a UTF-8 valid string.
|
header_str
|
rust
|
twilight-rs/twilight
|
twilight-http-ratelimiting/src/headers.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http-ratelimiting/src/headers.rs
|
ISC
|
fn wait_for_ticket(&self, path: Path) -> WaitForTicketFuture {
let get_ticket = self.ticket(path);
Box::pin(async move {
match get_ticket.await {
Ok(rx) => rx.await.map_err(From::from),
Err(e) => Err(e),
}
})
}
|
Retrieve a ticket to send a request.
Other than [`Self::ticket`], this method will return
a [`TicketSender`].
This is identical to calling [`Self::ticket`] and then
awaiting the [`TicketReceiver`].
|
wait_for_ticket
|
rust
|
twilight-rs/twilight
|
twilight-http-ratelimiting/src/lib.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http-ratelimiting/src/lib.rs
|
ISC
|
pub fn new(path: Path) -> Self {
Self {
limit: AtomicU64::new(u64::MAX),
path,
queue: BucketQueue::default(),
remaining: AtomicU64::new(u64::MAX),
reset_after: AtomicU64::new(u64::MAX),
started_at: Mutex::new(None),
}
}
|
Create a new bucket for the specified [`Path`].
|
new
|
rust
|
twilight-rs/twilight
|
twilight-http-ratelimiting/src/in_memory/bucket.rs
|
https://github.com/twilight-rs/twilight/blob/master/twilight-http-ratelimiting/src/in_memory/bucket.rs
|
ISC
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.