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

Function handle_discord_error

components/runtime/src/extensions/discord.rs:353–372  ·  view source on GitHub ↗
(state: &Rc<RefCell<OpState>>, err: twilight_http::Error)

Source from the content-addressed store, hash-verified

351}
352
353pub fn handle_discord_error(state: &Rc<RefCell<OpState>>, err: twilight_http::Error) -> AnyError {
354 let kind = err.kind();
355 if let ErrorType::Response { status, .. } = kind {
356 // check if this guild has run into a lot of "invalid" requests
357 //
358 // this is needed because discord will ban our IP if we exceed 10_000 invalid req/10min as of writing
359 let raw = status.get();
360 let _ = check_bad_request(state, raw);
361 }
362
363 match kind {
364 ErrorType::Response {
365 // 10008 is unknown message
366 error: ApiError::General(GeneralApiError { code, message, .. }),
367 status,
368 body,
369 } => error_from_code(*status, *code, message, body),
370 _ => err.into(),
371 }
372}
373
374pub fn error_from_code(
375 resp_code: StatusCode,

Callers 4

discord_request_retryFunction · 0.85
discord_request_anyFunction · 0.85
discord_requestFunction · 0.85

Calls 4

check_bad_requestFunction · 0.85
error_from_codeFunction · 0.85
kindMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected