[−][src]Struct serenity_utils::menu::Menu
A fully functioning reaction-based menu.
A reaction menu is a paginated message where the user can use reactions to change the page/content of the message.
Example
use serenity_utils::{ menu::{Menu, MenuOptions}, Error }; async fn use_menu(ctx: &Context, msg: &Message) -> Result<(), Error> { let mut message_one = CreateMessage::default(); message_one .content("Page number one!") .embed(|e| { e.description("The first page!"); e }); let mut message_two = CreateMessage::default(); message_two .content("Page number two!") .embed(|e| { e.description("The second page!"); e }); let pages = [message_one, message_two]; // Creates a new menu. let menu = Menu::new(ctx, msg, &pages, MenuOptions::default()); // Runs the menu and returns optional `Message` used to display the menu. let opt_message = menu.run().await?; Ok(()) }
A reaction menu can be configured by changing its options. See
MenuOptions
for more details.
Fields
ctx: &'a Context
The Discord/serenity context.
msg: &'a Message
The invocation message.
pages: &'a [CreateMessage<'a>]
The pages of the menu.
options: MenuOptions
The menu options.
Implementations
impl<'a> Menu<'a>
[src]
pub fn new(
ctx: &'a Context,
msg: &'a Message,
pages: &'a [CreateMessage<'a>],
options: MenuOptions
) -> Self
[src]
ctx: &'a Context,
msg: &'a Message,
pages: &'a [CreateMessage<'a>],
options: MenuOptions
) -> Self
Creates a new Menu
object.
pub async fn run(self) -> Result<Option<Message>, Error>
[src]
Runs the reaction menu.
It returns the message used to display the reaction menu after running.
Errors
Returns Error::SerenityError
if
- current user/bot doesn't have the permissions to add reactions
msg
is specified inMenuOptions
but the current user/bot isn't the author of the message- the message content lengths are over Discord's limit
- current user/bot doesn't have the permissions to send an message/embed
Returns Error::InvalidChoice
if the user selects an invalid choice, ie, reacts to an
emoji that does not correspond to any control
.
Returns Error::Other
if
pages
is empty- the page number specified in
MenuOptions
is out of bounds
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Menu<'a>
impl<'a> Send for Menu<'a>
impl<'a> Sync for Menu<'a>
impl<'a> Unpin for Menu<'a>
impl<'a> !UnwindSafe for Menu<'a>
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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[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, 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.
pub 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.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
pub fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,