List all registered slash commands. Returns a list of dicts with keys: `name`, `description`, `usage` (or `None`). Slash commands can be invoked via `session.send("/command args")`.
(&self, py: Python<'py>)
| 3241 | /// Returns a list of dicts with keys: `name`, `description`, `usage` (or `None`). |
| 3242 | /// Slash commands can be invoked via `session.send("/command args")`. |
| 3243 | fn list_commands<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyList>> { |
| 3244 | let commands = self.inner.command_registry().list_full(); |
| 3245 | let items: Vec<_> = commands |
| 3246 | .into_iter() |
| 3247 | .map(|(name, description, usage)| { |
| 3248 | let d = PyDict::new(py); |
| 3249 | let _ = d.set_item("name", &name); |
| 3250 | let _ = d.set_item("description", &description); |
| 3251 | let _ = d.set_item("usage", usage.as_deref()); |
| 3252 | d.into_any() |
| 3253 | }) |
| 3254 | .collect(); |
| 3255 | PyList::new(py, &items) |
| 3256 | } |
| 3257 | |
| 3258 | /// Register a custom slash command with a Python callback. |
| 3259 | /// |
nothing calls this directly
no test coverage detected