[−][src]Enum serenity::model::error::Error
An error returned from the model
module.
This is always wrapped within the library's Error::Model
variant.
Examples
Matching an Error
with this variant would look something like the
following for the GuildId::ban
method, which in this example is used to
re-ban all members with an odd discriminator:
use serenity::prelude::*; use serenity::model::prelude::*; use serenity::Error; use serenity::model::ModelError; use std::env; struct Handler; impl EventHandler for Handler { fn guild_ban_removal(&self, context: Context, guild_id: GuildId, user: User) { // If the user has an even discriminator, don't re-ban them. if user.discriminator % 2 == 0 { return; } match guild_id.ban(&context.http, user, &8) { Ok(()) => { // Ban successful. }, Err(Error::Model(ModelError::DeleteMessageDaysAmount(amount))) => { println!("Failed deleting {} days' worth of messages", amount); }, Err(why) => { println!("Unexpected error: {:?}", why); }, } } } let token = env::var("DISCORD_BOT_TOKEN")?; let mut client = Client::new(&token, Handler).unwrap(); client.start()?;
Variants
When attempting to delete below or above the minimum and maximum allowed number of messages.
DeleteMessageDaysAmount(u8)
When attempting to delete a number of days' worth of messages that is not allowed.
EmbedTooLarge(u64)
Indicates that the textual content of an embed exceeds the maximum length.
Indicates that there are hierarchy problems restricting an action.
For example, when banning a user, if the other user has a role with an equal to or higher position, then they can not be banned.
When editing a role, if the role is higher in position than the current user's highest role, then the role can not be edited.
InvalidPermissions(Permissions)
Indicates that you do not have the required permissions to perform an operation.
The provided Permission
s is the set of required permissions
required.
An indicator that the current user cannot perform an action.
An indicator that an item is missing from the Cache
, and the action
can not be continued.
MessageTooLong(u64)
Indicates that a Message
s content was too long and will not
successfully send, as the length is over 2000 codepoints, or 4000 bytes.
The number of bytes larger than the limit is provided.
Indicates that the current user is attempting to Direct Message another bot user, which is disallowed by the API.
An indicator that the ChannelType
cannot perform an action.
Trait Implementations
impl Clone for Error
[src]
impl Debug for Error
[src]
impl Display for Error
[src]
impl Eq for Error
[src]
impl Error for Error
[src]
fn source(&self) -> Option<&(dyn Error + 'static)>
1.30.0[src]
fn backtrace(&self) -> Option<&Backtrace>
[src]
fn description(&self) -> &str
1.0.0[src]
fn cause(&self) -> Option<&dyn Error>
1.0.0[src]
impl From<Error> for Error
[src]
fn from(e: ModelError) -> Error
[src]
impl Hash for Error
[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 PartialEq<Error> for Error
[src]
impl StructuralEq for Error
[src]
impl StructuralPartialEq for Error
[src]
Auto Trait Implementations
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnwindSafe for Error
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 + Send + Sync> where
T: Send + Sync,
[src]
T: Send + Sync,
impl<T> DebugAny for T where
T: Any + Debug,
[src]
T: Any + Debug,
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> UnsafeAny for T where
T: Any,
T: Any,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,