feat: introduce new life

This commit is contained in:
Suiranoil
2023-07-04 06:21:00 +03:00
parent 7e1aaa6cb6
commit b681f1b1fa
7 changed files with 3830 additions and 13 deletions

1
.gitignore vendored
View File

@@ -6,6 +6,5 @@ mixer_discord_bot.iml
.vscode
# Rust
Cargo.lock
Secrets.toml
target/

3813
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,4 @@
[workspace]
members = [
"mixer-discord-bot"
]

View File

@@ -10,10 +10,10 @@ serenity = {version = "0.11.5", default-features = false, features = ["rustls_ba
sqlx = { version = "0.6.3", features = ["runtime-tokio-rustls", "postgres"] }
sea-orm = { version = "0.11.3", features = ["sqlx-postgres", "runtime-tokio-rustls", "macros"] }
itertools = "0.10.5"
shuttle-secrets = "0.18.0"
shuttle-serenity = "0.18.0"
shuttle-runtime = "0.18.0"
shuttle-shared-db = { version = "0.18.0", features = ["postgres-rustls"] }
shuttle-secrets = "0.19.0"
shuttle-serenity = "0.19.0"
shuttle-runtime = "0.19.0"
shuttle-shared-db = { version = "0.19.0", features = ["postgres-rustls"] }
rusttype = "0.9.3"
image = "0.24.6"

View File

@@ -4,12 +4,10 @@ pub mod interactions;
use serenity::async_trait;
use serenity::client::{Context, EventHandler};
use serenity::http::CacheHttp;
use serenity::model::application::command::Command;
use serenity::model::application::interaction::{Interaction, InteractionResponseType};
use serenity::model::gateway::Ready;
use serenity::model::prelude::VoiceState;
use std::collections::HashMap;
use tracing::log::info;
use crate::bot::commands::MixerCommand;

View File

@@ -12,7 +12,7 @@ pub struct ImageGenerator<'a> {
impl<'a> ImageGenerator<'a> {
pub fn draw_teams_to_vec(&self, player_names: Vec<String>, teams_rating: [i32; 2], format: ImageOutputFormat) -> Vec<u8> {
let mut image: image::ImageBuffer<image::Rgb<u8>, Vec<u8>> = self.teams_image.clone();
let mut image = self.teams_image.clone();
let player_text_scale = Scale::uniform(60.0);
for i in 0..2 {

View File

@@ -1,8 +1,8 @@
mod algorithm;
mod bot;
mod database;
mod mixer;
mod image_manipulation;
mod mixer;
use bot::commands::creator::CreatorCommand;
use image_manipulation::{ImageGenerator, ImageGeneratorContainer};
@@ -79,9 +79,17 @@ async fn serenity(
data.insert::<CreatorContainer>(Arc::new(creator));
let image_generator = ImageGenerator {
player_font: Font::try_from_bytes(include_bytes!("../assets/fonts/big-noodle-too-oblique.ttf")).unwrap(),
text_font: Font::try_from_bytes(include_bytes!("../assets/fonts/big-noodle-titling.ttf")).unwrap(),
teams_image: image::load_from_memory(include_bytes!("../assets/images/teams.png")).unwrap().to_rgb8()
player_font: Font::try_from_bytes(include_bytes!(
"../assets/fonts/big-noodle-too-oblique.ttf"
))
.unwrap(),
text_font: Font::try_from_bytes(include_bytes!(
"../assets/fonts/big-noodle-titling.ttf"
))
.unwrap(),
teams_image: image::load_from_memory(include_bytes!("../assets/images/teams.png"))
.unwrap()
.to_rgb8(),
};
data.insert::<ImageGeneratorContainer>(Arc::new(image_generator));
}