Skip to content

Commit

Permalink
add autocompleting to more tag commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacherr committed Sep 14, 2024
1 parent bbae631 commit 500733e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion assyst-core/src/command/autocomplete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ pub async fn handle_autocomplete(
let opts = match command_full_name {
"cooltext create" => cooltext_options_autocomplete(),
// FIXME: this unwrap needs handling properly when tags come to dms etc
"tag run" => tag_names_autocomplete(assyst.clone(), guild_id.unwrap().get()).await,
"tag run" | "tag raw" | "tag copy" | "tag info" => {
tag_names_autocomplete(assyst.clone(), guild_id.unwrap().get()).await
},
_ => {
err!("Trying to autocomplete for invalid command: {command_full_name} (arg {option})");
return;
Expand Down
6 changes: 3 additions & 3 deletions assyst-core/src/command/misc/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ pub async fn list(ctxt: CommandCtxt<'_>, user: Option<User>, flags: TagListFlags
examples = ["test", "script"],
guild_only = true
)]
pub async fn info(ctxt: CommandCtxt<'_>, name: Word) -> anyhow::Result<()> {
pub async fn info(ctxt: CommandCtxt<'_>, name: WordAutocomplete) -> anyhow::Result<()> {
let Some(guild_id) = ctxt.data.guild_id else {
bail!("Tag information can only be fetched in guilds.")
};
Expand Down Expand Up @@ -576,7 +576,7 @@ pub async fn info(ctxt: CommandCtxt<'_>, name: Word) -> anyhow::Result<()> {
examples = ["test", "script"],
guild_only = true
)]
pub async fn raw(ctxt: CommandCtxt<'_>, name: Word) -> anyhow::Result<()> {
pub async fn raw(ctxt: CommandCtxt<'_>, name: WordAutocomplete) -> anyhow::Result<()> {
let Some(guild_id) = ctxt.data.guild_id else {
bail!("Tag raw content can only be fetched in guilds.")
};
Expand Down Expand Up @@ -806,7 +806,7 @@ pub async fn backup(ctxt: CommandCtxt<'_>) -> anyhow::Result<()> {
examples = ["test", "script"],
guild_only = true
)]
pub async fn copy(ctxt: CommandCtxt<'_>, name: Word) -> anyhow::Result<()> {
pub async fn copy(ctxt: CommandCtxt<'_>, name: WordAutocomplete) -> anyhow::Result<()> {
let Some(guild_id) = ctxt.data.guild_id else {
bail!("Tags can only be copied from guilds.")
};
Expand Down

0 comments on commit 500733e

Please sign in to comment.