MCPcopy Create free account
hub / github.com/Botloader/botloader / discord_request_any

Function discord_request_any

components/runtime/src/extensions/discord.rs:273–291  ·  view source on GitHub ↗
(
    state: &Rc<RefCell<OpState>>,
    f: impl Future<Output = Result<T, AnyError>> + Send + 'static,
)

Source from the content-addressed store, hash-verified

271}
272
273pub async fn discord_request_any<T: Send + Sync + 'static>(
274 state: &Rc<RefCell<OpState>>,
275 f: impl Future<Output = Result<T, AnyError>> + Send + 'static,
276) -> Result<T, AnyError> {
277 let rt_handle = {
278 let state = state.borrow();
279 let rt_ctx: &RuntimeContext = state.borrow();
280 rt_ctx.main_tokio_runtime.clone()
281 };
282
283 rt_handle
284 .spawn(f)
285 .await
286 .unwrap()
287 .map_err(|err| match err.downcast::<twilight_http::Error>() {
288 Ok(discord_err) => handle_discord_error(state, discord_err),
289 Err(err) => err,
290 })
291}
292
293pub async fn discord_request<T: Send + Sync + 'static>(
294 state: &Rc<RefCell<OpState>>,

Calls 2

handle_discord_errorFunction · 0.85
spawnMethod · 0.45

Tested by

no test coverage detected