[−][src]Struct serenity::model::id::GuildId
An identifier for a Guild
Methods
impl GuildId
[src]
pub fn ban<U, BO>(
self,
http: impl AsRef<Http>,
user: U,
ban_options: &BO
) -> Result<()> where
U: Into<UserId>,
BO: BanOptions,
[src]
self,
http: impl AsRef<Http>,
user: U,
ban_options: &BO
) -> Result<()> where
U: Into<UserId>,
BO: BanOptions,
Ban a User
from the guild. All messages by the
user within the last given number of days given will be deleted.
Refer to the documentation for Guild::ban
for more information.
Note: Requires the Ban Members permission.
Examples
Ban a member and remove all messages they've sent in the last 4 days:
use serenity::model::id::GuildId; // assuming a `user` has already been bound let _ = GuildId(81384788765712384).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, http: impl AsRef<Http>) -> Result<Vec<Ban>>
[src]
Gets a list of the guild's bans.
Requires the Ban Members permission.
pub fn audit_logs(
self,
http: impl AsRef<Http>,
action_type: Option<u8>,
user_id: Option<UserId>,
before: Option<AuditLogEntryId>,
limit: Option<u8>
) -> Result<AuditLogs>
[src]
self,
http: impl AsRef<Http>,
action_type: Option<u8>,
user_id: Option<UserId>,
before: Option<AuditLogEntryId>,
limit: Option<u8>
) -> Result<AuditLogs>
Gets a list of the guild's audit log entries
pub fn channels(
self,
http: impl AsRef<Http>
) -> Result<HashMap<ChannelId, GuildChannel>>
[src]
self,
http: impl AsRef<Http>
) -> Result<HashMap<ChannelId, GuildChannel>>
Gets all of the guild's channels over the REST API.
pub fn create_channel(
self,
http: impl AsRef<Http>,
f: impl FnOnce(&mut CreateChannel) -> &mut CreateChannel
) -> Result<GuildChannel>
[src]
self,
http: impl AsRef<Http>,
f: impl FnOnce(&mut CreateChannel) -> &mut CreateChannel
) -> Result<GuildChannel>
Creates a GuildChannel
in the 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::id::GuildId; use serenity::model::channel::ChannelType; let _channel = GuildId(7).create_channel(|c| c.name("test").kind(ChannelType::Voice));
pub fn create_emoji(
self,
http: impl AsRef<Http>,
name: &str,
image: &str
) -> Result<Emoji>
[src]
self,
http: impl AsRef<Http>,
name: &str,
image: &str
) -> Result<Emoji>
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,
http: impl AsRef<Http>,
integration_id: I,
kind: &str
) -> Result<()> where
I: Into<IntegrationId>,
[src]
self,
http: impl AsRef<Http>,
integration_id: I,
kind: &str
) -> Result<()> where
I: Into<IntegrationId>,
Creates an integration for the guild.
Requires the Manage Guild permission.
pub fn create_role<F>(self, http: impl AsRef<Http>, f: F) -> Result<Role> where
F: FnOnce(&mut EditRole) -> &mut EditRole,
[src]
F: FnOnce(&mut EditRole) -> &mut EditRole,
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.
pub fn delete(self, http: impl AsRef<Http>) -> Result<PartialGuild>
[src]
Deletes the current guild if the current account is the owner of the guild.
Refer to Guild::delete
for more information.
Note: Requires the current user to be the owner of the guild.
pub fn delete_emoji<E: Into<EmojiId>>(
self,
http: impl AsRef<Http>,
emoji_id: E
) -> Result<()>
[src]
self,
http: impl AsRef<Http>,
emoji_id: E
) -> Result<()>
Deletes an Emoji
from the guild.
Requires the Manage Emojis permission.
pub fn delete_integration<I: Into<IntegrationId>>(
self,
http: impl AsRef<Http>,
integration_id: I
) -> Result<()>
[src]
self,
http: impl AsRef<Http>,
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,
http: impl AsRef<Http>,
role_id: R
) -> Result<()>
[src]
self,
http: impl AsRef<Http>,
role_id: R
) -> Result<()>
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, http: impl AsRef<Http>, f: F) -> Result<PartialGuild> where
F: FnOnce(&mut EditGuild) -> &mut EditGuild,
[src]
F: FnOnce(&mut EditGuild) -> &mut EditGuild,
Edits the current guild with new data where specified.
Refer to Guild::edit
for more information.
Note: Requires the current user to have the Manage Guild permission.
pub fn edit_emoji<E: Into<EmojiId>>(
self,
http: impl AsRef<Http>,
emoji_id: E,
name: &str
) -> Result<Emoji>
[src]
self,
http: impl AsRef<Http>,
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,
http: impl AsRef<Http>,
user_id: U,
f: F
) -> Result<()> where
F: FnOnce(&mut EditMember) -> &mut EditMember,
U: Into<UserId>,
[src]
self,
http: impl AsRef<Http>,
user_id: U,
f: F
) -> Result<()> where
F: FnOnce(&mut EditMember) -> &mut 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:
guild.edit_member(&context, user_id, |m| m.mute(true).roles(&vec![role_id]));
pub fn edit_nickname(
self,
http: impl AsRef<Http>,
new_nickname: Option<&str>
) -> Result<()>
[src]
self,
http: impl AsRef<Http>,
new_nickname: Option<&str>
) -> Result<()>
Edits the current user's nickname for the guild.
Pass None
to reset the nickname.
Requires the Change Nickname permission.
pub fn edit_role<F, R>(
self,
http: impl AsRef<Http>,
role_id: R,
f: F
) -> Result<Role> where
F: FnOnce(&mut EditRole) -> &mut EditRole,
R: Into<RoleId>,
[src]
self,
http: impl AsRef<Http>,
role_id: R,
f: F
) -> Result<Role> where
F: FnOnce(&mut EditRole) -> &mut EditRole,
R: Into<RoleId>,
Edits a Role
, optionally setting its new fields.
Requires the Manage Roles permission.
Examples
Make a role hoisted:
use serenity::model::{GuildId, RoleId}; GuildId(7).edit_role(&context, RoleId(8), |r| r.hoist(true));
pub fn edit_role_position<R>(
self,
http: impl AsRef<Http>,
role_id: R,
position: u64
) -> Result<Vec<Role>> where
R: Into<RoleId>,
[src]
self,
http: impl AsRef<Http>,
role_id: R,
position: u64
) -> Result<Vec<Role>> where
R: Into<RoleId>,
Edits the order of Role
s
Requires the Manage Roles permission.
Examples
Change the order of a role:
use serenity::model::{GuildId, RoleId}; GuildId(7).edit_role_position(&context, RoleId(8), 2);
pub fn to_guild_cached(
self,
cache: impl AsRef<CacheRwLock>
) -> Option<Arc<RwLock<Guild>>>
[src]
self,
cache: impl AsRef<CacheRwLock>
) -> Option<Arc<RwLock<Guild>>>
Tries to find the Guild
by its Id in the cache.
pub fn to_partial_guild(self, http: impl AsRef<Http>) -> Result<PartialGuild>
[src]
Requests PartialGuild
over REST API.
Note: This will not be a Guild
, as the REST API does not send
all data with a guild retrieval.
pub 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 fn invites(self, http: impl AsRef<Http>) -> Result<Vec<RichInvite>>
[src]
Gets all of the guild's invites.
Requires the Manage Guild permission.
pub fn kick<U: Into<UserId>>(
self,
http: impl AsRef<Http>,
user_id: U
) -> Result<()>
[src]
self,
http: impl AsRef<Http>,
user_id: U
) -> Result<()>
Kicks a Member
from the guild.
Requires the Kick Members permission.
pub fn leave(self, http: impl AsRef<Http>) -> Result<()>
[src]
Leaves the guild.
pub fn member<U: Into<UserId>>(
self,
cache_http: impl CacheHttp,
user_id: U
) -> Result<Member>
[src]
self,
cache_http: impl CacheHttp,
user_id: U
) -> Result<Member>
Gets a user's Member
for the guild by Id.
If the cache feature is enabled the cache will be checked first. If not found it will resort to an http request.
pub fn members<U>(
self,
http: impl AsRef<Http>,
limit: Option<u64>,
after: U
) -> Result<Vec<Member>> where
U: Into<Option<UserId>>,
[src]
self,
http: impl AsRef<Http>,
limit: Option<u64>,
after: U
) -> Result<Vec<Member>> where
U: Into<Option<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 members_iter<H: AsRef<Http>>(self, http: H) -> MembersIter<H>
[src]
Iterates over all the members in a guild.
This is accomplished and equivilent to repeated calls to [members
].
A buffer of at most 1,000 members is used to reduce the number of calls
necessary.
Examples
for member_result in guild_id.members_iter(&ctx) { match member_result { Ok(member) => println!( "{} is {}", member, member.display_name() ), Err(error) => eprintln!("Uh oh! Error: {}", error), } }
pub fn move_member<C, U>(
self,
http: impl AsRef<Http>,
user_id: U,
channel_id: C
) -> Result<()> where
C: Into<ChannelId>,
U: Into<UserId>,
[src]
self,
http: impl AsRef<Http>,
user_id: U,
channel_id: C
) -> Result<()> where
C: Into<ChannelId>,
U: Into<UserId>,
Moves a member to a specific voice channel.
Requires the Move Members permission.
pub fn prune_count(
self,
http: impl AsRef<Http>,
days: u16
) -> Result<GuildPrune>
[src]
self,
http: impl AsRef<Http>,
days: u16
) -> Result<GuildPrune>
Gets the number of Member
s that would be pruned with the given
number of days.
Requires the Kick Members permission.
pub fn reorder_channels<It>(
self,
http: impl AsRef<Http>,
channels: It
) -> Result<()> where
It: IntoIterator<Item = (ChannelId, u64)>,
[src]
self,
http: impl AsRef<Http>,
channels: It
) -> Result<()> where
It: IntoIterator<Item = (ChannelId, u64)>,
Re-orders the channels of the guild.
Accepts an iterator of a tuple of the channel ID to modify and its new position.
Although not required, you should specify all channels' positions, regardless of whether they were updated. Otherwise, positioning can sometimes get weird.
pub fn shard_id(self, cache: impl AsRef<CacheRwLock>) -> 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 start_integration_sync<I: Into<IntegrationId>>(
self,
http: impl AsRef<Http>,
integration_id: I
) -> Result<()>
[src]
self,
http: impl AsRef<Http>,
integration_id: I
) -> Result<()>
Starts an integration sync for the given integration Id.
Requires the Manage Guild permission.
pub fn start_prune(
self,
http: impl AsRef<Http>,
days: u16
) -> Result<GuildPrune>
[src]
self,
http: impl AsRef<Http>,
days: u16
) -> Result<GuildPrune>
Starts a prune of Member
s.
See the documentation on GuildPrune
for more information.
Note: Requires the Kick Members permission.
pub fn unban<U: Into<UserId>>(
self,
http: impl AsRef<Http>,
user_id: U
) -> Result<()>
[src]
self,
http: impl AsRef<Http>,
user_id: U
) -> Result<()>
Unbans a User
from the guild.
Requires the Ban Members permission.
pub 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 fn webhooks(self, http: impl AsRef<Http>) -> Result<Vec<Webhook>>
[src]
Retrieves the guild's webhooks.
Note: Requires the Manage Webhooks permission.
impl GuildId
[src]
pub fn created_at(&self) -> DateTime<FixedOffset>
[src]
Retrieves the time that the Id was created at.
pub fn as_u64(&self) -> &u64
[src]
Immutably borrow inner Id.
pub fn as_mut_u64(&mut self) -> &mut u64
[src]
Mutably borrow inner Id.
Trait Implementations
impl AsRef<GuildId> for GuildId
[src]
impl Clone for GuildId
[src]
impl Copy for GuildId
[src]
impl Debug for GuildId
[src]
impl Default for GuildId
[src]
impl<'de> Deserialize<'de> for GuildId
[src]
fn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> StdResult<Self, D::Error>
[src]
deserializer: D
) -> StdResult<Self, D::Error>
impl Display for GuildId
[src]
impl Eq for GuildId
[src]
impl<'a> From<&'a Guild> for GuildId
[src]
impl<'a> From<&'a GuildId> for GuildId
[src]
impl<'a> From<&'a GuildInfo> for GuildId
[src]
impl<'a> From<&'a InviteGuild> for GuildId
[src]
fn from(invite_guild: &InviteGuild) -> GuildId
[src]
Gets the Id of Invite Guild struct.
impl<'a> From<&'a PartialGuild> for GuildId
[src]
fn from(guild: &PartialGuild) -> GuildId
[src]
Gets the Id of a partial guild.
impl From<Guild> for GuildId
[src]
impl From<GuildId> for GuildContainer
[src]
fn from(guild_id: GuildId) -> GuildContainer
[src]
impl From<GuildId> for u64
[src]
impl From<GuildId> for i64
[src]
impl From<GuildInfo> for GuildId
[src]
impl From<InviteGuild> for GuildId
[src]
fn from(invite_guild: InviteGuild) -> GuildId
[src]
Gets the Id of Invite Guild struct.
impl From<PartialGuild> for GuildId
[src]
fn from(guild: PartialGuild) -> GuildId
[src]
Gets the Id of a partial guild.
impl From<u64> for GuildId
[src]
impl Hash for GuildId
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for GuildId
[src]
fn cmp(&self, other: &GuildId) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<GuildId> for GuildId
[src]
impl PartialEq<u64> for GuildId
[src]
impl PartialOrd<GuildId> for GuildId
[src]
fn partial_cmp(&self, other: &GuildId) -> Option<Ordering>
[src]
fn lt(&self, other: &GuildId) -> bool
[src]
fn le(&self, other: &GuildId) -> bool
[src]
fn gt(&self, other: &GuildId) -> bool
[src]
fn ge(&self, other: &GuildId) -> bool
[src]
impl Serialize for GuildId
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralEq for GuildId
[src]
impl StructuralPartialEq for GuildId
[src]
Auto Trait Implementations
impl RefUnwindSafe for GuildId
impl Send for GuildId
impl Sync for GuildId
impl Unpin for GuildId
impl UnwindSafe for GuildId
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
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 + Sync + Send> where
T: Send + Sync,
[src]
T: Send + Sync,
impl<T> DebugAny for T where
T: Any + Debug,
[src]
T: Any + Debug,
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
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, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,
impl<T> UnsafeAny for T where
T: Any,
T: Any,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,