[−][src]Struct serenity::model::guild::PartialGuild
Partial information about a Guild
. This does not include information
like member data.
Fields
id: GuildId
afk_channel_id: Option<ChannelId>
afk_timeout: u64
default_message_notifications: DefaultMessageNotificationLevel
embed_channel_id: Option<ChannelId>
embed_enabled: bool
emojis: HashMap<EmojiId, Emoji>
features: Vec<String>
Features enabled for the guild.
Refer to Guild::features
for more information.
icon: Option<String>
mfa_level: MfaLevel
name: String
owner_id: UserId
region: String
roles: HashMap<RoleId, Role>
splash: Option<String>
verification_level: VerificationLevel
Methods
impl PartialGuild
[src]
pub fn ban<U: Into<UserId>>(
&self,
user: U,
delete_message_days: u8
) -> Result<()>
[src]
&self,
user: U,
delete_message_days: u8
) -> Result<()>
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:
// 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 fn bans(&self) -> Result<Vec<Ban>>
[src]
Gets a list of the guild's bans.
Requires the Ban Members permission.
pub fn channels(&self) -> Result<HashMap<ChannelId, GuildChannel>>
[src]
Gets all of the guild's channels over the REST API.
pub fn create_channel<C>(
&self,
name: &str,
kind: ChannelType,
category: C
) -> Result<GuildChannel> where
C: Into<Option<ChannelId>>,
[src]
&self,
name: &str,
kind: ChannelType,
category: C
) -> Result<GuildChannel> where
C: Into<Option<ChannelId>>,
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
:
use serenity::model::ChannelType; guild.create_channel("test", ChannelType::Voice, None);
pub fn create_emoji(&self, 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 fn create_integration<I>(&self, integration_id: I, kind: &str) -> Result<()> where
I: Into<IntegrationId>,
[src]
I: Into<IntegrationId>,
Creates an integration for the guild.
Requires the Manage Guild permission.
pub fn create_role<F: FnOnce(EditRole) -> EditRole>(&self, f: F) -> Result<Role>
[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 fn delete(&self) -> 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 fn delete_emoji<E: Into<EmojiId>>(&self, emoji_id: E) -> Result<()>
[src]
Deletes an Emoji
from the guild.
Requires the Manage Emojis permission.
pub fn delete_integration<I: Into<IntegrationId>>(
&self,
integration_id: I
) -> Result<()>
[src]
&self,
integration_id: I
) -> Result<()>
Deletes an integration by Id from the guild.
Requires the Manage Guild permission.
pub fn delete_role<R: Into<RoleId>>(&self, role_id: R) -> 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 fn edit<F>(&mut self, f: F) -> Result<()> where
F: FnOnce(EditGuild) -> EditGuild,
[src]
F: FnOnce(EditGuild) -> EditGuild,
Edits the current guild with new data where specified.
Note: Requires the current user to have the Manage Guild permission.
pub fn edit_emoji<E: Into<EmojiId>>(
&self,
emoji_id: E,
name: &str
) -> Result<Emoji>
[src]
&self,
emoji_id: E,
name: &str
) -> Result<Emoji>
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 fn edit_member<F, U>(&self, user_id: U, f: F) -> Result<()> where
F: FnOnce(EditMember) -> EditMember,
U: Into<UserId>,
[src]
F: FnOnce(EditMember) -> EditMember,
U: Into<UserId>,
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:
use serenity::model::GuildId; GuildId(7).edit_member(user_id, |m| m.mute(true).roles(&vec![role_id]));
pub fn edit_nickname(&self, 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 fn get<G: Into<GuildId>>(guild_id: G) -> Result<PartialGuild>
[src]
Gets a partial amount of guild data by its Id.
Requires that the current user be in the guild.
pub fn kick<U: Into<UserId>>(&self, user_id: U) -> Result<()>
[src]
Kicks a Member
from the guild.
Requires the Kick Members permission.
pub fn icon_url(&self) -> Option<String>
[src]
Returns a formatted URL of the guild's icon, if the guild has an icon.
pub fn integrations(&self) -> Result<Vec<Integration>>
[src]
Gets all integration of the guild.
This performs a request over the REST API.
pub fn invites(&self) -> Result<Vec<RichInvite>>
[src]
Gets all of the guild's invites.
Requires the Manage Guild permission.
pub fn leave(&self) -> Result<()>
[src]
Leaves the guild.
pub fn member<U: Into<UserId>>(&self, user_id: U) -> Result<Member>
[src]
Gets a user's Member
for the guild by Id.
pub fn members<U>(
&self,
limit: Option<u64>,
after: Option<U>
) -> Result<Vec<Member>> where
U: Into<UserId>,
[src]
&self,
limit: Option<u64>,
after: Option<U>
) -> Result<Vec<Member>> where
U: Into<UserId>,
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 fn move_member<C, U>(&self, user_id: U, channel_id: C) -> Result<()> where
C: Into<ChannelId>,
U: Into<UserId>,
[src]
C: Into<ChannelId>,
U: Into<UserId>,
Moves a member to a specific voice channel.
Requires the Move Members permission.
pub fn prune_count(&self, days: u16) -> Result<GuildPrune>
[src]
Gets the number of Member
s that would be pruned with the given
number of days.
Requires the Kick Members permission.
pub fn shard_id(&self) -> 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 fn start_integration_sync<I: Into<IntegrationId>>(
&self,
integration_id: I
) -> Result<()>
[src]
&self,
integration_id: I
) -> Result<()>
Starts an integration sync for the given integration Id.
Requires the Manage Guild permission.
pub fn unban<U: Into<UserId>>(&self, user_id: U) -> Result<()>
[src]
Unbans a User
from the guild.
Requires the Ban Members permission.
pub fn vanity_url(&self) -> Result<String>
[src]
Retrieve's the guild's vanity URL.
Note: Requires the Manage Guild permission.
pub fn webhooks(&self) -> 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; use serenity::CACHE; impl EventHandler for Handler { fn message(&self, _: Context, msg: Message) { let guild = msg.guild_id().unwrap().to_partial_guild().unwrap(); let possible_role = guild.role_by_name("role_name"); if let Some(role) = possible_role { println!("Obtained role's reference: {:?}", role); } } } let mut client = Client::new("token", Handler).unwrap(); client.start().unwrap();
Trait Implementations
impl Clone for PartialGuild
[src]
fn clone(&self) -> PartialGuild
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl From<PartialGuild> for GuildId
[src]
fn from(guild: PartialGuild) -> GuildId
[src]
Gets the Id of a partial guild.
impl<'a> From<&'a PartialGuild> for GuildId
[src]
fn from(guild: &PartialGuild) -> GuildId
[src]
Gets the Id of a partial guild.
impl From<PartialGuild> for GuildContainer
[src]
fn from(guild: PartialGuild) -> GuildContainer
[src]
impl Debug for PartialGuild
[src]
impl Serialize for PartialGuild
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de> Deserialize<'de> for PartialGuild
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl Send for PartialGuild
impl Sync for PartialGuild
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> Erased for T
impl<T> Typeable for T where
T: Any,
T: Any,
impl<T> DebugAny for T where
T: Any + Debug,
[src]
T: Any + Debug,
impl<T> CloneAny for T where
T: Clone + Any,
[src]
T: Clone + Any,
fn clone_any(&self) -> Box<dyn CloneAny + 'static>
[src]
fn clone_any_send(&self) -> Box<dyn CloneAny + 'static + Send> where
T: Send,
[src]
T: Send,
fn clone_any_sync(&self) -> Box<dyn CloneAny + 'static + Sync> where
T: Sync,
[src]
T: Sync,
fn clone_any_send_sync(&self) -> Box<dyn CloneAny + 'static + Send + Sync> where
T: Send + Sync,
[src]
T: Send + Sync,
impl<T> UnsafeAny for T where
T: Any,
T: Any,