[][src]Struct serenity::model::guild::PartialGuild

pub struct PartialGuild {
    pub id: GuildId,
    pub afk_channel_id: Option<ChannelId>,
    pub afk_timeout: u64,
    pub default_message_notifications: DefaultMessageNotificationLevel,
    pub embed_channel_id: Option<ChannelId>,
    pub embed_enabled: bool,
    pub emojis: HashMap<EmojiId, Emoji>,
    pub features: Vec<String>,
    pub icon: Option<String>,
    pub mfa_level: MfaLevel,
    pub name: String,
    pub owner_id: UserId,
    pub region: String,
    pub roles: HashMap<RoleId, Role>,
    pub splash: Option<String>,
    pub verification_level: VerificationLevel,
    pub description: Option<String>,
    pub premium_tier: PremiumTier,
    pub premium_subscription_count: u64,
    pub banner: Option<String>,
    pub vanity_url_code: Option<String>,
    // some fields omitted
}

Partial information about a Guild. This does not include information like member data.

Fields

id: GuildIdafk_channel_id: Option<ChannelId>afk_timeout: u64default_message_notifications: DefaultMessageNotificationLevelembed_channel_id: Option<ChannelId>embed_enabled: boolemojis: HashMap<EmojiId, Emoji>features: Vec<String>

Features enabled for the guild.

Refer to Guild::features for more information.

icon: Option<String>mfa_level: MfaLevelname: Stringowner_id: UserIdregion: Stringroles: HashMap<RoleId, Role>splash: Option<String>verification_level: VerificationLeveldescription: Option<String>premium_tier: PremiumTierpremium_subscription_count: u64banner: Option<String>vanity_url_code: Option<String>

Implementations

impl PartialGuild[src]

pub async fn ban<'_>(
    &'_ self,
    http: impl AsRef<Http>,
    user: impl Into<UserId>,
    dmd: u8
) -> Result<()>
[src]

Ban a User from the guild, deleting a number of days' worth of messages (dmd) between the range 0 and 7.

Note: Requires the Ban Members permission.

Examples

Ban a member and remove all messages they've sent in the last 4 days:

This example is not tested
// assumes a `user` and `guild` have already been bound
let _ = guild.ban(user, 4);

Errors

Returns a ModelError::DeleteMessageDaysAmount if the number of days' worth of messages to delete is over the maximum.

pub async fn ban_with_reason<'_>(
    &'_ self,
    http: impl AsRef<Http>,
    user: impl Into<UserId>,
    dmd: u8,
    reason: impl AsRef<str>
) -> Result<()>
[src]

Ban a User from the guild with a reason. Refer to ban to further documentation.

pub async fn bans<'_>(&'_ self, http: impl AsRef<Http>) -> Result<Vec<Ban>>[src]

Gets a list of the guild's bans.

Requires the Ban Members permission.

pub async fn channels<'_>(
    &'_ self,
    http: impl AsRef<Http>
) -> Result<HashMap<ChannelId, GuildChannel>>
[src]

Gets all of the guild's channels over the REST API.

pub async fn create_channel<'_>(
    &'_ self,
    http: impl AsRef<Http>,
    f: impl FnOnce(&mut CreateChannel) -> &mut CreateChannel
) -> Result<GuildChannel>
[src]

Creates a GuildChannel in the guild.

Refer to Http::create_channel for more information.

Requires the Manage Channels permission.

Examples

Create a voice channel in a guild with the name test:

This example is not tested
use serenity::model::ChannelType;

guild.create_channel(|c| c.name("test").kind(ChannelType::Voice));

pub async fn create_emoji<'_, '_, '_>(
    &'_ self,
    http: impl AsRef<Http>,
    name: &'_ str,
    image: &'_ str
) -> Result<Emoji>
[src]

Creates an emoji in the guild with a name and base64-encoded image.

Refer to the documentation for Guild::create_emoji for more information.

Requires the Manage Emojis permission.

Examples

See the EditProfile::avatar example for an in-depth example as to how to read an image from the filesystem and encode it as base64. Most of the example can be applied similarly for this method.

pub async fn create_integration<I, '_, '_>(
    &'_ self,
    http: impl AsRef<Http>,
    integration_id: impl Into<IntegrationId>,
    kind: &'_ str
) -> Result<()>
[src]

Creates an integration for the guild.

Requires the Manage Guild permission.

pub async fn create_role<F, '_>(
    &'_ self,
    http: impl AsRef<Http>,
    f: F
) -> Result<Role> where
    F: FnOnce(&mut EditRole) -> &mut EditRole
[src]

Creates a new role in the guild with the data set, if any.

See the documentation for Guild::create_role on how to use this.

Note: Requires the Manage Roles permission.

Errors

If the cache is enabled, returns a ModelError::InvalidPermissions if the current user does not have permission to perform bans.

pub async fn delete<'_>(
    &'_ self,
    http: impl AsRef<Http>
) -> Result<PartialGuild>
[src]

Deletes the current guild if the current user is the owner of the guild.

Note: Requires the current user to be the owner of the guild.

pub async fn delete_emoji<'_>(
    &'_ self,
    http: impl AsRef<Http>,
    emoji_id: impl Into<EmojiId>
) -> Result<()>
[src]

Deletes an Emoji from the guild.

Requires the Manage Emojis permission.

pub async fn delete_integration<'_>(
    &'_ self,
    http: impl AsRef<Http>,
    integration_id: impl Into<IntegrationId>
) -> Result<()>
[src]

Deletes an integration by Id from the guild.

Requires the Manage Guild permission.

pub async fn delete_role<'_>(
    &'_ self,
    http: impl AsRef<Http>,
    role_id: impl Into<RoleId>
) -> Result<()>
[src]

Deletes a Role by Id from the guild.

Also see Role::delete if you have the cache and methods features enabled.

Requires the Manage Roles permission.

pub async fn edit<F, '_>(
    &'_ mut self,
    http: impl AsRef<Http>,
    f: F
) -> Result<()> where
    F: FnOnce(&mut EditGuild) -> &mut EditGuild
[src]

Edits the current guild with new data where specified.

Note: Requires the current user to have the Manage Guild permission.

pub async fn edit_emoji<'_, '_>(
    &'_ self,
    http: impl AsRef<Http>,
    emoji_id: impl Into<EmojiId>,
    name: &'_ str
) -> Result<Emoji>
[src]

Edits an Emoji's name in the guild.

Also see Emoji::edit if you have the cache and methods features enabled.

Requires the Manage Emojis permission.

pub async fn edit_member<F, '_>(
    &'_ self,
    http: impl AsRef<Http>,
    user_id: impl Into<UserId>,
    f: F
) -> Result<()> where
    F: FnOnce(&mut EditMember) -> &mut EditMember
[src]

Edits the properties of member of the guild, such as muting or nicknaming them.

Refer to EditMember's documentation for a full list of methods and permission restrictions.

Examples

Mute a member and set their roles to just one role with a predefined Id:

This example is not tested
use serenity::model::GuildId;

GuildId(7).edit_member(user_id, |m| m.mute(true).roles(&vec![role_id])).await;

pub async fn edit_nickname<'_, '_>(
    &'_ self,
    http: impl AsRef<Http>,
    new_nickname: Option<&'_ str>
) -> Result<()>
[src]

Edits the current user's nickname for the guild.

Pass None to reset the nickname.

Note: Requires the Change Nickname permission.

Errors

If the cache is enabled, returns a ModelError::InvalidPermissions if the current user does not have permission to change their own nickname.

pub async fn get(
    http: impl AsRef<Http>,
    guild_id: impl Into<GuildId>
) -> Result<PartialGuild>
[src]

Gets a partial amount of guild data by its Id.

Requires that the current user be in the guild.

pub async fn kick<'_>(
    &'_ self,
    http: impl AsRef<Http>,
    user_id: impl Into<UserId>
) -> Result<()>
[src]

Kicks a Member from the guild.

Requires the Kick Members permission.

pub async fn kick_with_reason<'_, '_>(
    &'_ self,
    http: impl AsRef<Http>,
    user_id: impl Into<UserId>,
    reason: &'_ str
) -> Result<()>
[src]

pub fn icon_url(&self) -> Option<String>[src]

Returns a formatted URL of the guild's icon, if the guild has an icon.

pub async fn emojis<'_>(&'_ self, http: impl AsRef<Http>) -> Result<Vec<Emoji>>[src]

Gets all Emojis of this guild via HTTP.

pub async fn emoji<'_>(
    &'_ self,
    http: impl AsRef<Http>,
    emoji_id: EmojiId
) -> Result<Emoji>
[src]

Gets an Emoji of this guild by its ID via HTTP.

pub async fn integrations<'_>(
    &'_ self,
    http: impl AsRef<Http>
) -> Result<Vec<Integration>>
[src]

Gets all integration of the guild.

This performs a request over the REST API.

pub async fn invites<'_>(
    &'_ self,
    http: impl AsRef<Http>
) -> Result<Vec<RichInvite>>
[src]

Gets all of the guild's invites.

Requires the Manage Guild permission.

pub async fn leave<'_>(&'_ self, http: impl AsRef<Http>) -> Result<()>[src]

Leaves the guild.

pub async fn member<'_>(
    &'_ self,
    cache_http: impl CacheHttp,
    user_id: impl Into<UserId>
) -> Result<Member>
[src]

Gets a user's Member for the guild by Id.

pub async fn members<'_>(
    &'_ self,
    http: impl AsRef<Http>,
    limit: Option<u64>,
    after: impl Into<Option<UserId>>
) -> Result<Vec<Member>>
[src]

Gets a list of the guild's members.

Optionally pass in the limit to limit the number of results. Maximum value is 1000. Optionally pass in after to offset the results by a User's Id.

pub async fn move_member<'_>(
    &'_ self,
    http: impl AsRef<Http>,
    user_id: impl Into<UserId>,
    channel_id: impl Into<ChannelId>
) -> Result<()>
[src]

Moves a member to a specific voice channel.

Requires the Move Members permission.

pub async fn prune_count<'_>(
    &'_ self,
    http: impl AsRef<Http>,
    days: u16
) -> Result<GuildPrune>
[src]

Gets the number of Members that would be pruned with the given number of days.

Requires the Kick Members permission.

pub async fn shard_id<'_>(&'_ self, cache: impl AsRef<Cache>) -> u64[src]

Returns the Id of the shard associated with the guild.

When the cache is enabled this will automatically retrieve the total number of shards.

Note: When the cache is enabled, this function unlocks the cache to retrieve the total number of shards in use. If you already have the total, consider using utils::shard_id.

pub fn splash_url(&self) -> Option<String>[src]

Returns the formatted URL of the guild's splash image, if one exists.

pub async fn start_integration_sync<'_>(
    &'_ self,
    http: impl AsRef<Http>,
    integration_id: impl Into<IntegrationId>
) -> Result<()>
[src]

Starts an integration sync for the given integration Id.

Requires the Manage Guild permission.

pub async fn unban<'_>(
    &'_ self,
    http: impl AsRef<Http>,
    user_id: impl Into<UserId>
) -> Result<()>
[src]

Unbans a User from the guild.

Requires the Ban Members permission.

pub async fn vanity_url<'_>(&'_ self, http: impl AsRef<Http>) -> Result<String>[src]

Retrieve's the guild's vanity URL.

Note: Requires the Manage Guild permission.

pub async fn webhooks<'_>(
    &'_ self,
    http: impl AsRef<Http>
) -> Result<Vec<Webhook>>
[src]

Retrieves the guild's webhooks.

Note: Requires the Manage Webhooks permission.

pub fn role_by_name(&self, role_name: &str) -> Option<&Role>[src]

Obtain a reference to a role by its name.

Note: If two or more roles have the same name, obtained reference will be one of them.

Examples

Obtain a reference to a Role by its name.

use serenity::model::prelude::*;
use serenity::prelude::*;

struct Handler;

#[serenity::async_trait]
impl EventHandler for Handler {
    async fn message(&self, context: Context, msg: Message) {
        if let Some(guild_id) = msg.guild_id {
            if let Some(guild) = guild_id.to_guild_cached(&context).await {
                if let Some(role) = guild.role_by_name("role_name") {
                    println!("Obtained role's reference: {:?}", role);
                }
            }
        }
    }
}

let mut client =Client::builder("token").event_handler(Handler).await?;

client.start().await?;

pub fn await_reply<'a>(
    &self,
    shard_messenger: &'a impl AsRef<ShardMessenger>
) -> CollectReply<'a>

Notable traits for CollectReply<'a>

impl<'a> Future for CollectReply<'a> type Output = Option<Arc<Message>>;
[src]

Returns a future that will await one message sent in this guild.

pub fn await_replies<'a>(
    &self,
    shard_messenger: &'a impl AsRef<ShardMessenger>
) -> MessageCollectorBuilder<'a>

Notable traits for MessageCollectorBuilder<'a>

impl<'a> Future for MessageCollectorBuilder<'a> type Output = MessageCollector;
[src]

Returns a stream builder which can be awaited to obtain a stream of messages in this guild.

pub fn await_reaction<'a>(
    &self,
    shard_messenger: &'a impl AsRef<ShardMessenger>
) -> CollectReaction<'a>

Notable traits for CollectReaction<'a>

impl<'a> Future for CollectReaction<'a> type Output = Option<Arc<ReactionAction>>;
[src]

Await a single reaction in this guild.

pub fn await_reactions<'a>(
    &self,
    shard_messenger: &'a impl AsRef<ShardMessenger>
) -> ReactionCollectorBuilder<'a>
[src]

Returns a stream builder which can be awaited to obtain a stream of reactions sent in this guild.

Trait Implementations

impl Clone for PartialGuild[src]

impl Debug for PartialGuild[src]

impl<'de> Deserialize<'de> for PartialGuild[src]

impl<'a> From<&'a PartialGuild> for GuildId[src]

pub fn from(guild: &PartialGuild) -> GuildId[src]

Gets the Id of a partial guild.

impl From<PartialGuild> for GuildId[src]

pub fn from(guild: PartialGuild) -> GuildId[src]

Gets the Id of a partial guild.

impl From<PartialGuild> for GuildContainer[src]

impl Serialize for PartialGuild[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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

impl<T> WithSubscriber for T[src]