Skip to content

Commit

Permalink
Merge pull request #1328 from HTGAzureX1212/nightly
Browse files Browse the repository at this point in the history
`/info role`: Obtain Role From Cache
  • Loading branch information
HTGAzureX1212 authored Aug 13, 2023
2 parents 5b53f10 + cd67261 commit 4b71b76
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions api-backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
use hartex_discord_core::discord::model::application::interaction::application_command::CommandDataOption;
use hartex_discord_core::discord::model::application::interaction::application_command::CommandOptionValue;
use hartex_discord_core::discord::model::application::interaction::Interaction;
use hartex_discord_entitycache_core::traits::Repository;
use hartex_discord_entitycache_repositories::role::CachedRoleRepository;
use hartex_discord_utils::CLIENT;
use hartex_localization_core::create_bundle;
use miette::IntoDiagnostic;

pub async fn execute(interaction: Interaction, option: CommandDataOption) -> miette::Result<()> {
let CommandOptionValue::SubCommand(options) = option.value else {
Expand All @@ -37,13 +40,15 @@ pub async fn execute(interaction: Interaction, option: CommandDataOption) -> mie
&["discord-frontend", "commands"],
)?;

let CommandOptionValue::Role(_) = options
let CommandOptionValue::Role(role_id) = options
.iter()
.find(|option| option.name.as_str() == "role")
.map(|option| option.value.clone())
.unwrap() else {
unreachable!();
};

let _ = CachedRoleRepository.get((interaction.guild_id.unwrap(), role_id)).await.into_diagnostic()?;

Ok(())
}

0 comments on commit 4b71b76

Please sign in to comment.