Added Cargo.toml + No warnings
This commit is contained in:
parent
23ffc50659
commit
d5b3f3cff0
6 changed files with 54 additions and 2037 deletions
2016
Cargo.lock
generated
2016
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
17
Cargo.toml
Normal file
17
Cargo.toml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
[package]
|
||||||
|
name = "obsessed-yanqing"
|
||||||
|
version = "1.0.0"
|
||||||
|
edition = "2021"
|
||||||
|
authors = ["Evann Regnault"]
|
||||||
|
license = "MIT"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serenity = { version="0.11.5", features=["builder", "client", "gateway", "model", "utils", "collector"], default-features = false }
|
||||||
|
poise = { version="0.5.2" }
|
||||||
|
serde_json = "1.0.95"
|
||||||
|
serde_derive = "1.0.159"
|
||||||
|
tokio = { version="1.28.0", features = ["macros", "rt-multi-thread"] }
|
||||||
|
levenshtein = "1.0.5"
|
||||||
|
reqwest = "0.11.17"
|
||||||
|
serde = "1.0.160"
|
||||||
|
serde_path_to_error = "0.1.11"
|
|
@ -1,24 +1,13 @@
|
||||||
use std::any::Any;
|
|
||||||
use std::borrow::Cow;
|
|
||||||
use std::fmt::format;
|
|
||||||
use std::future::Future;
|
|
||||||
use std::ops::{Deref, DerefMut};
|
|
||||||
use std::pin::Pin;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use async_recursion::async_recursion;
|
use poise::ReplyHandle;
|
||||||
use poise::{BoxFuture, ReplyHandle};
|
use serenity::builder::{CreateButton, CreateComponents, CreateEmbed, CreateEmbedFooter};
|
||||||
use poise::futures_util::FutureExt;
|
|
||||||
use serenity::builder::{CreateButton, CreateComponents, CreateEmbed, CreateEmbedFooter, CreateInteractionResponseData};
|
|
||||||
use serenity::model::application::component::ButtonStyle;
|
use serenity::model::application::component::ButtonStyle;
|
||||||
use serenity::model::application::interaction::InteractionResponseType;
|
|
||||||
use serenity::model::application::interaction::message_component::MessageComponentInteraction;
|
use serenity::model::application::interaction::message_component::MessageComponentInteraction;
|
||||||
use serenity::model::channel::Message;
|
|
||||||
use serenity::utils::{Color, MessageBuilder};
|
|
||||||
use crate::data::{Context, Error};
|
use crate::data::{Context, Error};
|
||||||
use crate::data::allcharacters::{Characters, get_nearest_characters};
|
use crate::data::allcharacters::{Characters, get_nearest_characters};
|
||||||
use crate::data::character::{Character, Description, get_character_data, Review};
|
use crate::data::character::{Character, get_character_data};
|
||||||
use crate::data::description::{Content2, get_all_texts};
|
use crate::data::description::get_all_texts;
|
||||||
use crate::data::proscons::get_proscons_texts;
|
use crate::data::proscons::get_proscons_texts;
|
||||||
use crate::utils::color_manager::get_element_color;
|
use crate::utils::color_manager::get_element_color;
|
||||||
use crate::utils::emote_manager::{get_element_emote, get_path_emote};
|
use crate::utils::emote_manager::{get_element_emote, get_path_emote};
|
||||||
|
@ -79,7 +68,7 @@ async fn get_character_review(character: &Character) -> Option<CreateEmbed> {
|
||||||
let cons = match cons_data {
|
let cons = match cons_data {
|
||||||
None => { "".to_string() }
|
None => { "".to_string() }
|
||||||
Some(data) => {
|
Some(data) => {
|
||||||
let mut all_texts: Vec<String> = get_proscons_texts(&data).unwrap_or(vec![]).into_iter().map(|x| format!("• {}", x)).collect();
|
let all_texts: Vec<String> = get_proscons_texts(&data).unwrap_or(vec![]).into_iter().map(|x| format!("• {}", x)).collect();
|
||||||
all_texts.join("\n")
|
all_texts.join("\n")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -88,7 +77,7 @@ async fn get_character_review(character: &Character) -> Option<CreateEmbed> {
|
||||||
let pros = match pros_data {
|
let pros = match pros_data {
|
||||||
None => { "".to_string() }
|
None => { "".to_string() }
|
||||||
Some(data) => {
|
Some(data) => {
|
||||||
let mut all_texts: Vec<String> = get_proscons_texts(&data).unwrap_or(vec![]).into_iter().map(|x| format!("• {}", x)).collect();
|
let all_texts: Vec<String> = get_proscons_texts(&data).unwrap_or(vec![]).into_iter().map(|x| format!("• {}", x)).collect();
|
||||||
all_texts.join("\n")
|
all_texts.join("\n")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -207,7 +196,7 @@ async fn menu_handler(ctx: Context<'_>, interaction: Arc<MessageComponentInterac
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn choice_interaction_handler(ctx: Context<'_>, message: &ReplyHandle<'_>, tab: CharacterTab) {
|
async fn choice_interaction_handler(ctx: Context<'_>, message: &ReplyHandle<'_>) {
|
||||||
let message = message.clone().into_message().await.unwrap();
|
let message = message.clone().into_message().await.unwrap();
|
||||||
let interaction =
|
let interaction =
|
||||||
match message.await_component_interaction(&ctx).timeout(Duration::from_secs(60 * 3)).await {
|
match message.await_component_interaction(&ctx).timeout(Duration::from_secs(60 * 3)).await {
|
||||||
|
@ -244,7 +233,7 @@ pub async fn character(
|
||||||
None => { ctx.say(format!("Error occured")).await? }
|
None => { ctx.say(format!("Error occured")).await? }
|
||||||
Some(characters) => {
|
Some(characters) => {
|
||||||
let handler = create_menu(ctx, characters).await;
|
let handler = create_menu(ctx, characters).await;
|
||||||
choice_interaction_handler(ctx, &handler, CharacterTab::Home).await;
|
choice_interaction_handler(ctx, &handler).await;
|
||||||
handler
|
handler
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,7 +19,7 @@ pub struct Result<T: PrydwenCompatible> {
|
||||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct PageContext {
|
pub struct PageContext {
|
||||||
contentfulId: Option<String>
|
contentful_id: Option<String>
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait PrydwenCompatible {
|
pub trait PrydwenCompatible {
|
||||||
|
|
27
src/main.rs
Normal file
27
src/main.rs
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
mod commands;
|
||||||
|
mod data;
|
||||||
|
mod utils;
|
||||||
|
use poise::serenity_prelude::GatewayIntents;
|
||||||
|
use crate::data::Data;
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
// Build our client.
|
||||||
|
let framework = poise::Framework::builder()
|
||||||
|
.token(std::env::var("TOKEN").expect("No token found"))
|
||||||
|
.intents(GatewayIntents::non_privileged())
|
||||||
|
.options(poise::FrameworkOptions {
|
||||||
|
commands: vec![
|
||||||
|
commands::character::character()
|
||||||
|
],
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.setup(|ctx, _ready, framework| {
|
||||||
|
Box::pin(async move {
|
||||||
|
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
|
||||||
|
Ok(Data {})
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
framework.run().await.unwrap();
|
||||||
|
}
|
|
@ -13,7 +13,7 @@ pub fn get_element_color(name: &String) -> Color {
|
||||||
color_map.get(name.as_str()).unwrap_or(&Color::new(0)).to_owned()
|
color_map.get(name.as_str()).unwrap_or(&Color::new(0)).to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn get_path_color(name: &String) -> Color {
|
pub fn get_path_color(name: &String) -> Color {
|
||||||
let mut color_map = HashMap::new();
|
let mut color_map = HashMap::new();
|
||||||
color_map.insert("Abundance", Color::new(6410131));
|
color_map.insert("Abundance", Color::new(6410131));
|
||||||
|
|
Loading…
Reference in a new issue