refactor: ignore errors for unknown commands
This commit is contained in:
parent
137493320c
commit
74a810b956
@ -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,7 +58,9 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow:
|
|||||||
ncr_options: ncr_options.clone(),
|
ncr_options: ncr_options.clone(),
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
) {
|
)
|
||||||
|
&& error.type_ != DispatcherUnknownCommand
|
||||||
|
{
|
||||||
CommandSource {
|
CommandSource {
|
||||||
client,
|
client,
|
||||||
message,
|
message,
|
||||||
@ -64,7 +70,6 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow:
|
|||||||
.reply(&format!("{error:?}"));
|
.reply(&format!("{error:?}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let table = state.lua.create_table()?;
|
let table = state.lua.create_table()?;
|
||||||
table.set("text", text.to_string())?;
|
table.set("text", text.to_string())?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user