-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use scripty_bot_utils::{checks::is_guild, Context, Error}; | ||
use scripty_integrations::kiai::{get_kiai_api_client, Permissions as KiaiPermissions}; | ||
|
||
/// Enable Scripty's Kiai integration. You should disable Kiai's voice XP levelling if you use this. | ||
#[poise::command( | ||
prefix_command, | ||
slash_command, | ||
check = "is_guild", | ||
required_permissions = "MANAGE_GUILD", | ||
rename = "enable_kiai" | ||
)] | ||
pub async fn config_enable_kiai(ctx: Context<'_>, enable_kiai: Option<bool>) -> Result<(), Error> { | ||
let guild_id = ctx | ||
.guild_id() | ||
.map(|g| g.get()) | ||
.ok_or_else(Error::expected_guild)?; | ||
let resolved_language = | ||
scripty_i18n::get_resolved_language(ctx.author().id.get(), Some(guild_id)).await; | ||
|
||
let i18n_string = if let Some(enable_kiai) = enable_kiai { | ||
let kc = get_kiai_api_client(); | ||
let perms = kc.get_permissions(guild_id).await?; | ||
if perms.contains(KiaiPermissions::LEVELS) { | ||
sqlx::query!( | ||
"INSERT INTO guilds (guild_id, kiai_enabled) VALUES ($1, $2) ON CONFLICT \ | ||
(guild_id) DO UPDATE SET kiai_enabled = $2", | ||
guild_id as i64, | ||
enable_kiai | ||
) | ||
.execute(scripty_db::get_db()) | ||
.await?; | ||
|
||
if enable_kiai { | ||
"config-kiai-enabled" | ||
} else { | ||
"config-kiai-disabled" | ||
} | ||
} else { | ||
"config-kiai-missing-perms" | ||
} | ||
} else { | ||
"config-kiai-info" | ||
}; | ||
|
||
ctx.say(format_message!(resolved_language, i18n_string)) | ||
.await?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters