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

pub struct PartialGuild {
    pub id: GuildId,
    pub afk_channel_id: Option<ChannelId>,
    pub afk_timeout: u64,
    pub default_message_notifications: u64,
    pub embed_channel_id: Option<ChannelId>,
    pub embed_enabled: bool,
    pub emojis: HashMap<EmojiId, Emoji>,
    pub features: Vec<Feature>,
    pub icon: Option<String>,
    pub mfa_level: u64,
    pub name: String,
    pub owner_id: UserId,
    pub region: String,
    pub roles: HashMap<RoleId, Role>,
    pub splash: Option<String>,
    pub verification_level: VerificationLevel,
}

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

Fields

Methods

impl PartialGuild
[src]

[src]

Ban a User from the guild. All messages by the user within the last given number of days given will be deleted. This may be a range between 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:

Be careful when using this code, it's not being 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.

[src]

Gets a list of the guild's bans.

Requires the Ban Members permission.

[src]

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

[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:

Be careful when using this code, it's not being tested!
use serenity::model::ChannelType;

guild.create_channel("test", ChannelType::Voice);

[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.

[src]

Creates an integration for the guild.

Requires the Manage Guild permission.

[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.

[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.

[src]

Deletes an Emoji from the guild.

Requires the Manage Emojis permission.

[src]

Deletes an integration by Id from the guild.

Requires the Manage Guild permission.

[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.

[src]

Edits the current guild with new data where specified.

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

[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.

[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:

Be careful when using this code, it's not being tested!
use serenity::model::GuildId;

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

[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.

[src]

Gets a partial amount of guild data by its Id.

Requires that the current user be in the guild.

[src]

Kicks a Member from the guild.

Requires the Kick Members permission.

[src]

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

[src]

Gets all integration of the guild.

This performs a request over the REST API.

[src]

Gets all of the guild's invites.

Requires the Manage Guild permission.

[src]

Leaves the guild.

[src]

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

[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.

[src]

Moves a member to a specific voice channel.

Requires the Move Members permission.

[src]

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

Requires the Kick Members permission.

[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.

[src]

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

[src]

Starts an integration sync for the given integration Id.

Requires the Manage Guild permission.

[src]

Unbans a User from the guild.

Requires the Ban Members permission.

[src]

Retrieves the guild's webhooks.

Note: Requires the Manage Webhooks permission.

[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::*;
use serenity::prelude::*;

struct Handler;

use serenity::CACHE;

impl EventHandler for Handler {
    fn on_message(&self, _: Context, msg: Message) {
        if let Some(role) =
           msg.guild_id().unwrap().get().unwrap().role_by_name("role_name") {
            println!("Obtained role's reference: {:?}", role);
        }
    }
}

let mut client = Client::new("token", Handler);

client.start().unwrap();

Trait Implementations

impl Clone for PartialGuild
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for PartialGuild
[src]

[src]

Formats the value using the given formatter.