From 0f0027da27645503aabc3f84ded4243dc3d9ade4 Mon Sep 17 00:00:00 2001 From: Rafael Bradley Date: Sun, 10 Aug 2025 23:05:37 -0300 Subject: [PATCH] Add bot initialization docs for the framework module --- src/framework/mod.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/framework/mod.rs b/src/framework/mod.rs index f30c77e..5fb1f19 100644 --- a/src/framework/mod.rs +++ b/src/framework/mod.rs @@ -1,6 +1,45 @@ //! 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 = 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, +//! server_id: Option, +//! user_id: Option +//! ) -> Vec { +//! // The runtime contains your state at [`Runtime::state`]. +//! +//! vec!["p.".to_string()] +//! } +//! +//! let bot: Bot = Bot::new(state, get_prefixes); +//! ``` pub mod bot; pub mod commands;