Skip to content

Commit

Permalink
Merge pull request #104 from ValgulNecron/dev
Browse files Browse the repository at this point in the history
Fixed build
  • Loading branch information
ValgulNecron committed Mar 8, 2024
2 parents 59e7628 + 435aeb6 commit 3d8fa3a
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 80 deletions.
29 changes: 2 additions & 27 deletions .github/workflows/docker-image-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:
cancel-in-progress: false

jobs:
docker_amd64:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
Expand All @@ -28,32 +28,7 @@ jobs:
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/kasuki:dev
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILDKIT_INLINE_CACHE=1
docker_arm64:
needs: docker_amd64
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push arm64
id: docker_build_arm64
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/arm64/v8
platforms: linux/amd64,linux/arm64/v8
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/kasuki:dev
cache-from: type=gha
cache-to: type=gha,mode=max
Expand Down
29 changes: 2 additions & 27 deletions .github/workflows/docker-image-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:
cancel-in-progress: false

jobs:
docker_amd64:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
Expand All @@ -28,32 +28,7 @@ jobs:
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/kasuki:latest
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILDKIT_INLINE_CACHE=1
docker_arm64:
needs: docker_amd64
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push arm64
id: docker_build_arm64
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/arm64/v8
platforms: linux/amd64,linux/arm64/v8
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/kasuki:latest
cache-from: type=gha
cache-to: type=gha,mode=max
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kasuki"
version = "2.5.1"
version = "2.5.2"
edition = "2021"
authors = ["Valgul <contact@valgul.moe>"]
description = "A discord bot written in rust that get info from anilist API"
Expand Down
54 changes: 43 additions & 11 deletions json/message/general/info.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{
"en": {
"title": "Info",
"desc": "This bot uses the AniList API to provide information on a show or a user. \n The bot is on $number$ server. \n The bot version is: $version$",
"desc": "This bot uses the AniList API to provide information on a show or a user.",
"bot_name": "Bot name:",
"bot_id": "Bot ID:",
"server_count": "Server count:",
"user_count": "User count",
"creation_date": "Creation date",
"shard": "You are on shard:",
"shard_count": "Shard count:",
"version": "The version of the bot is:",
"footer": "Creator: valgul.",
"button_see_on_github": "See on GitHub",
"button_official_website": "Official website",
Expand All @@ -10,31 +18,55 @@
"button_add_the_beta_bot": "Add the beta bot"
},
"fr": {
"title": "Informations",
"desc": "Ce bot utilise l'API AniList pour fournir des informations sur une série ou un utilisateur. \n Le bot est sur $number$ serveur. \n La version du bot est : $version$",
"title": "Info",
"desc": "Ce bot utilise l'API AniList pour fournir des informations sur un spectacle ou un utilisateur.",
"bot_name": "Nom du bot :",
"bot_id": "ID du bot :",
"server_count": "Nombre de serveurs :",
"user_count": "Nombre d'utilisateurs",
"creation_date": "Date de création",
"shard": "Vous êtes sur le fragment :",
"shard_count": "Nombre de fragments :",
"version": "La version du bot est :",
"footer": "Créateur : valgul.",
"button_see_on_github": "Voir sur GitHub",
"button_official_website": "Site officiel",
"button_official_discord": "Discord officiel",
"button_add_the_bot": "Ajouter le bot",
"button_add_the_beta_bot": "Ajouter le bot beta"
"button_add_the_beta_bot": "Ajouter le bot bêta"
},
"jp": {
"title": "情報",
"desc": "このボットはAniList APIを使用して番組やユーザーの情報を提供します。 \n ボットは$number$サーバーにいます。 \n ボットのバージョンは:$version$",
"footer": "作成者:valgul。",
"desc": "このボットは、AniList APIを使用して番組またはユーザーに関する情報を提供します。",
"bot_name": "ボット名:",
"bot_id": "ボットID:",
"server_count": "サーバー数:",
"user_count": "ユーザー数",
"creation_date": "作成日",
"shard": "あなたはシャードにいます:",
"shard_count": "シャードの数:",
"version": "ボットのバージョンは:",
"footer": "クリエイター:valgul。",
"button_see_on_github": "GitHubで見る",
"button_official_website": "公式ウェブサイト",
"button_official_discord": "公式Discord",
"button_add_the_bot": "ボットを追加",
"button_add_the_beta_bot": "ベータ版ボットを追加"
"button_add_the_bot": "ボットを追加する",
"button_add_the_beta_bot": "ベータ版ボットを追加する"
},
"de": {
"title": "Info",
"desc": "Dieser Bot verwendet die AniList API, um Informationen zu einer Show oder einem Benutzer bereitzustellen. \n Der Bot ist auf $number$ Server. \n Die Bot-Version ist: $version$",
"footer": "Schöpfer: valgul.",
"desc": "Dieser Bot verwendet die AniList API, um Informationen zu einer Show oder einem Benutzer bereitzustellen.",
"bot_name": "Bot-Name:",
"bot_id": "Bot-ID:",
"server_count": "Serveranzahl:",
"user_count": "Benutzeranzahl",
"creation_date": "Erstellungsdatum",
"shard": "Du bist auf Shard:",
"shard_count": "Shard-Anzahl:",
"version": "Die Version des Bots lautet:",
"footer": "Ersteller: valgul.",
"button_see_on_github": "Auf GitHub ansehen",
"button_official_website": "Offizielle Website",
"button_official_website": "Offizielle Webseite",
"button_official_discord": "Offizieller Discord",
"button_add_the_bot": "Bot hinzufügen",
"button_add_the_beta_bot": "Beta-Bot hinzufügen"
Expand Down
46 changes: 40 additions & 6 deletions src/command_run/bot_info/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,50 @@ pub async fn run(ctx: &Context, command_interaction: &CommandInteraction) -> Res
None => String::from("0"),
};
let info_localised = load_localization_info(guild_id).await?;
let shard_count = ctx.cache.shard_count();
let shard = ctx.shard_id.to_string();
let user_count = ctx.cache.user_count();
let server_count = ctx.cache.guild_count();
let bot = ctx.http.get_current_application_info().await.map_err(|e| {
AppError::new(
format!("Error while getting the bot info {}", e),
ErrorType::Option,
ErrorResponseType::Message,
)
})?;
let bot_name = bot.name;
let bot_id = bot.id.to_string();
let creation_date = bot.id.created_at().to_rfc3339().unwrap_or_default();
let bot_icon = bot.icon.ok_or(AppError::new(
String::from("The bot has no avatar"),
ErrorType::Option,
ErrorResponseType::Message,
))?;
let avatar = if bot_icon.is_animated() {
format!(
"https://cdn.discordapp.com/icons/{}/{}.gif?size=1024",
bot_id, bot_icon
)
} else {
format!(
"https://cdn.discordapp.com/icons/{}/{}.webp?size=1024",
bot_id, bot_icon
)
};

let builder_embed = CreateEmbed::new()
.timestamp(Timestamp::now())
.color(COLOR)
.description(
info_localised
.desc
.replace("$number$", ctx.cache.guilds().len().to_string().as_str())
.replace("$version$", APP_VERSION),
)
.description(info_localised.desc)
.field(info_localised.bot_name, bot_name, true)
.field(info_localised.bot_id, bot_id, true)
.field(info_localised.version, APP_VERSION, true)
.field(info_localised.shard_count, shard_count.to_string(), true)
.field(info_localised.shard, shard, true)
.field(info_localised.user_count, user_count.to_string(), true)
.field(info_localised.server_count, server_count.to_string(), true)
.field(info_localised.creation_date, creation_date, true)
.thumbnail(avatar)
.title(&info_localised.title)
.footer(CreateEmbedFooter::new(&info_localised.footer));
let mut buttons = Vec::new();
Expand Down
12 changes: 6 additions & 6 deletions src/error_management/error_dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ pub async fn command_dispatching(
command_interaction: &CommandInteraction,
ctx: &Context,
) {
error!("{:?}", error);
error!("{}", error);
let response_type = error.error_response_type.clone();
match response_type {
ErrorResponseType::Message => match send_error(error, command_interaction, ctx).await {
Ok(_) => {}
Err(e) => {
error!("{:?}", e);
error!("{}", e);
}
},
ErrorResponseType::Followup => {
match send_differed_error(error, command_interaction, ctx).await {
Ok(_) => {}
Err(e) => {
error!("{:?}", e);
error!("{}", e);
}
}
}
Expand All @@ -35,7 +35,7 @@ pub async fn command_dispatching(
Err(_) => match send_differed_error(error, command_interaction, ctx).await {
Ok(_) => {}
Err(e) => {
error!("{:?}", e);
error!("{}", e);
}
},
}
Expand All @@ -51,7 +51,7 @@ async fn send_error(
) -> Result<(), AppError> {
let error_message = format!("**This error is most likely an error on your part. \
like you asking the bot to find unknown stuff or other. but in some case it's an error on my part juts check the \
error and report it to me and I will try to fix it the fastest I can** \n{:?}", e);
error and report it to me and I will try to fix it the fastest I can** \n{}", e);
let builder_embed = CreateEmbed::new()
.timestamp(Timestamp::now())
.color(COLOR)
Expand Down Expand Up @@ -81,7 +81,7 @@ async fn send_differed_error(
) -> Result<(), AppError> {
let error_message = format!("**This error is most likely an error on your part. \
like you asking the bot to find unknown stuff or other. but in some case it's an error on my part juts check the \
error and report it to me and I will try to fix it the fastest I can** \n{:?}", e);
error and report it to me and I will try to fix it the fastest I can** \n{}", e);
let builder_embed = CreateEmbed::new()
.timestamp(Timestamp::now())
.color(COLOR)
Expand Down
4 changes: 2 additions & 2 deletions src/error_management/error_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ impl fmt::Display for AppError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"Error type: {}. Error message: {}, Error response type: {}",
self.error_type, self.message, self.error_response_type
"Error type: {}. Error message: {}",
self.error_type, self.message
)
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/lang_struct/general/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ use crate::error_management::error_enum::{AppError, ErrorResponseType, ErrorType
pub struct InfoLocalised {
pub title: String,
pub desc: String,
pub bot_name: String,
pub bot_id: String,
pub server_count: String,
pub user_count: String,
pub creation_date: String,
pub shard: String,
pub shard_count: String,
pub version: String,
pub footer: String,
pub button_see_on_github: String,
pub button_official_website: String,
Expand Down

0 comments on commit 3d8fa3a

Please sign in to comment.