Files
payphone/src/framework/mod.rs
T

49 lines
1.6 KiB
Rust

//! A framework for building Discord bots, built with Twilight.
//!
//! Since Twilight is a low-level library, it can be hard to build a bot with it. Payphone's
//! framework provides a high-level interface for building Discord bots, with a focus on modularity
//! and ease of use. The framework is designed to be extensible, allowing you to add new features
//! and commands without modifying the core codebase. It also provides a set of utilities for
//! common tasks, such as sending messages, handling events, and managing state.
//!
//! # Creating a Bot
//!
//! Creating a bot with Payphone is as simple as creating a new instance of the `Bot` struct and
//! running it. The `Bot` struct is the main entry point for the framework and provides methods for
//! running the bot, handling events, and managing state.
//!
//! ```
//! use crate::framework::bot::Bot;
//!
//! // Your app's state.
//! let state = State::new();
//!
//! // Create a new bot instance with the state and a list of prefixes.
//! let bot: Bot<State> = Bot::new(state, ["p."]);
//! ```
//!
//! ## Prefixes
//!
//! The framework supports multiple prefixes per command and allows you to set them dynamically
//! based on server and user IDs.
//!
//! ```
//! async fn get_prefixes(
//! rt: &Runtime<State>,
//! server_id: Option<u64>,
//! user_id: Option<u64>
//! ) -> Vec<String> {
//! // The runtime contains your state at [`Runtime::state`].
//!
//! vec!["p.".to_string()]
//! }
//!
//! let bot: Bot<State> = Bot::new(state, get_prefixes);
//! ```
pub mod bot;
pub mod commands;
pub mod events;
pub mod interactions;
pub mod runtime;