refactor: ignore errors for unknown commands
This commit is contained in:
		| @@ -5,7 +5,10 @@ use crate::{ | |||||||
|     lua::{self, direction::Direction, player::Player, vec3::Vec3}, |     lua::{self, direction::Direction, player::Player, vec3::Vec3}, | ||||||
|     particle, |     particle, | ||||||
| }; | }; | ||||||
| use azalea::{prelude::*, protocol::packets::game::ClientboundGamePacket}; | use azalea::{ | ||||||
|  |     brigadier::exceptions::BuiltInExceptions::DispatcherUnknownCommand, prelude::*, | ||||||
|  |     protocol::packets::game::ClientboundGamePacket, | ||||||
|  | }; | ||||||
| use hyper::{server::conn::http1, service::service_fn}; | use hyper::{server::conn::http1, service::service_fn}; | ||||||
| use hyper_util::rt::TokioIo; | use hyper_util::rt::TokioIo; | ||||||
| use log::{debug, error, info, trace}; | use log::{debug, error, info, trace}; | ||||||
| @@ -44,8 +47,9 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow: | |||||||
|                     info!("decrypted message from {sender}: {content}"); |                     info!("decrypted message from {sender}: {content}"); | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 if is_whisper && globals.get::<Vec<String>>("Owners")?.contains(sender) { |                 if is_whisper | ||||||
|                     if let Err(error) = state.commands.execute( |                     && globals.get::<Vec<String>>("Owners")?.contains(sender) | ||||||
|  |                     && let Err(error) = state.commands.execute( | ||||||
|                         content.clone(), |                         content.clone(), | ||||||
|                         CommandSource { |                         CommandSource { | ||||||
|                             client: client.clone(), |                             client: client.clone(), | ||||||
| @@ -54,15 +58,16 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow: | |||||||
|                             ncr_options: ncr_options.clone(), |                             ncr_options: ncr_options.clone(), | ||||||
|                         } |                         } | ||||||
|                         .into(), |                         .into(), | ||||||
|                     ) { |                     ) | ||||||
|                         CommandSource { |                     && error.type_ != DispatcherUnknownCommand | ||||||
|                             client, |                 { | ||||||
|                             message, |                     CommandSource { | ||||||
|                             state: state.clone(), |                         client, | ||||||
|                             ncr_options, |                         message, | ||||||
|                         } |                         state: state.clone(), | ||||||
|                         .reply(&format!("{error:?}")); |                         ncr_options, | ||||||
|                     } |                     } | ||||||
|  |                     .reply(&format!("{error:?}")); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user