phoenixcord_sdk/lib.rs
1/*
2 * PhoenixCord, a Discord client mod
3 * Copyright (c) 2026 Leclowndu93150 and contributors
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
7//! Rust bindings for the PhoenixCord plugin API.
8//!
9//! Implement [`Plugin`] and export it with [`plugin!`]. Build the crate as a `cdylib` for the
10//! `wasm32-wasip2` target to get a component PhoenixCord can load.
11//!
12//! ```ignore
13//! use phoenixcord_sdk::types::{Hook, OutgoingMessage, PluginInfo, SendDecision};
14//! use phoenixcord_sdk::Plugin;
15//!
16//! #[derive(Default)]
17//! struct Shout;
18//!
19//! impl Plugin for Shout {
20//! fn info() -> PluginInfo {
21//! PluginInfo {
22//! hooks: vec![Hook::MessagePreSend],
23//! ..PluginInfo::new("Shout", "Sends every message in capitals", &["you"])
24//! }
25//! }
26//!
27//! fn pre_send(&mut self, message: OutgoingMessage) -> SendDecision {
28//! SendDecision::Replace(message.content.to_uppercase())
29//! }
30//! }
31//!
32//! phoenixcord_sdk::plugin!(Shout);
33//! ```
34
35#![allow(clippy::all, clippy::pedantic)]
36
37wit_bindgen::generate!({
38 path: "wit",
39 world: "phoenixcord",
40 pub_export_macro: true,
41 default_bindings_module: "phoenixcord_sdk",
42});
43
44mod plugin;
45mod view;
46
47pub use exports::phoenixcord::sdk::plugin::Guest;
48pub use phoenixcord::sdk::{actions, client, host, types};
49pub use plugin::Plugin;
50pub use view::View;