Skip to content

Commit

Permalink
properly check a command exists before disabling it
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacherr committed Jan 24, 2025
1 parent 364d60a commit c7cdaa7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions assyst-core/src/command/misc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use assyst_proc_macro::command;
use assyst_string_fmt::{Ansi, Markdown};

use super::arguments::{Codeblock, Image, ImageUrl, RestNoFlags, Word};
use super::registry::get_or_init_commands;
use super::registry::{find_command_by_name, get_or_init_commands};
use super::{Category, CommandCtxt};
use crate::command::Availability;
use crate::rest::charinfo::{extract_page_title, get_char_info};
Expand Down Expand Up @@ -362,9 +362,12 @@ pub async fn command(ctxt: CommandCtxt<'_>, command: Word) -> anyhow::Result<()>
let Some(guild_id) = ctxt.data.guild_id else {
bail!("Enabling or disabling commands is only supported in servers.")
};

let cmd = find_command_by_name(&command.0).context("That command doesn't exist.")?;

let command_obj = GuildDisabledCommand {
guild_id: guild_id.get() as _,
command_name: command.0,
command_name: cmd.metadata().name.to_owned(),
};

let is_disabled = command_obj
Expand Down

0 comments on commit c7cdaa7

Please sign in to comment.