Skip to content

Commit 08d7517

Browse files
author
Your Name
committed
remove libavacado part 1
1 parent dd011a1 commit 08d7517

31 files changed

+410
-2602
lines changed

.DS_Store

0 Bytes
Binary file not shown.

Cargo.lock

Lines changed: 5 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[workspace]
2-
members = ["bot", "libavacado"]
2+
members = ["bot"]

bot/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,22 @@ sqlx = { version = "0.6", features = [ "runtime-tokio-rustls", "postgres", "chro
1616
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls", "rustls-tls-native-roots"] }
1717
chrono = { version = "0.4", features = ["serde"]}
1818
futures-util = "0.3"
19-
libavacado = { path = "../libavacado" }
2019
ring = "0.16"
2120
data-encoding = "2.3"
2221
indexmap = { version = "1.9.1", features = ["serde"] }
2322
moka = { version = "0.9", features = ["future"] }
2423
ts-rs = "6.2"
2524
axum = "0.6"
2625
tower-http = { version = "0.3", features = ["cors"] }
26+
rand = "0.8"
27+
serde_yaml = "0.9"
28+
once_cell = "1.17"
2729

2830
[dependencies.tokio]
2931
version = "1"
3032
default-features = true
3133
features = ["fs", "macros", "rt", "sync", "time", "rt-multi-thread"]
34+
35+
[build-dependencies]
36+
vergen = "7"
37+
anyhow = "1.0"
File renamed without changes.

bot/src/_utils.rs

Lines changed: 0 additions & 54 deletions
This file was deleted.

bot/src/admin.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::Context;
22
use crate::Error;
3-
use crate::_checks as checks;
3+
use crate::checks;
4+
use crate::impls;
45

56
use poise::serenity_prelude::CreateActionRow;
67
use poise::serenity_prelude::CreateButton;
@@ -49,9 +50,9 @@ pub async fn approveonboard(
4950
.await?;
5051

5152
if onboard_state.staff_onboard_state
52-
!= libavacado::onboarding::OnboardState::PendingManagerReview.as_str()
53+
!= crate::onboarding::OnboardState::PendingManagerReview.as_str()
5354
&& onboard_state.staff_onboard_state
54-
!= libavacado::onboarding::OnboardState::Denied.as_str()
55+
!= crate::onboarding::OnboardState::Denied.as_str()
5556
{
5657
return Err(format!(
5758
"User is not pending manager review and currently has state of: {}",
@@ -63,7 +64,7 @@ pub async fn approveonboard(
6364
// Update onboard state of user
6465
sqlx::query!(
6566
"UPDATE users SET staff_onboard_state = $1 WHERE user_id = $2",
66-
libavacado::onboarding::OnboardState::Completed.as_str(),
67+
crate::onboarding::OnboardState::Completed.as_str(),
6768
member.id.to_string()
6869
)
6970
.execute(&data.pool)
@@ -106,7 +107,7 @@ pub async fn denyonboard(
106107
.await?;
107108

108109
if onboard_state.staff_onboard_state
109-
!= libavacado::onboarding::OnboardState::PendingManagerReview.as_str()
110+
!= crate::onboarding::OnboardState::PendingManagerReview.as_str()
110111
{
111112
return Err(format!(
112113
"User is not pending manager review and currently has state of: {}",
@@ -118,7 +119,7 @@ pub async fn denyonboard(
118119
// Update onboard state of user
119120
sqlx::query!(
120121
"UPDATE users SET staff_onboard_state = $1 WHERE user_id = $2",
121-
libavacado::onboarding::OnboardState::Denied.as_str(),
122+
crate::onboarding::OnboardState::Denied.as_str(),
122123
user.id.to_string()
123124
)
124125
.execute(&data.pool)
@@ -187,7 +188,7 @@ pub async fn resetonboard(
187188
// Update onboard state of user
188189
sqlx::query!(
189190
"UPDATE users SET staff_onboard_guild = NULL, staff_onboard_state = $1, staff_onboard_last_start_time = NOW() WHERE user_id = $2",
190-
libavacado::onboarding::OnboardState::Pending.as_str(),
191+
crate::onboarding::OnboardState::Pending.as_str(),
191192
user.id.to_string()
192193
)
193194
.execute(&data.pool)
@@ -216,7 +217,7 @@ pub async fn voteresetbot(
216217
) -> Result<(), crate::Error> {
217218
let data = ctx.data();
218219

219-
libavacado::manage::vote_reset_bot(
220+
impls::actions::vote_reset_bot(
220221
&data.cache_http,
221222
&data.pool,
222223
&bot.id.to_string(),
@@ -244,7 +245,7 @@ pub async fn voteresetallbots(
244245
) -> Result<(), crate::Error> {
245246
let data = ctx.data();
246247

247-
libavacado::manage::vote_reset_all_bot(
248+
impls::actions::vote_reset_all_bot(
248249
&data.cache_http,
249250
&data.pool,
250251
&ctx.author().id.to_string(),
@@ -272,7 +273,7 @@ pub async fn unverifybot(
272273
) -> Result<(), crate::Error> {
273274
let data = ctx.data();
274275

275-
libavacado::manage::unverify_bot(
276+
impls::actions::unverify_bot(
276277
&data.cache_http,
277278
&data.pool,
278279
&bot.id.to_string(),

bot/src/botowners.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::_checks as checks;
1+
use crate::{checks, config};
22
use poise::serenity_prelude::RoleId;
33

44
type Error = crate::Error;
@@ -108,8 +108,8 @@ pub async fn getbotroles(ctx: Context<'_>) -> Result<(), Error> {
108108
let mut roles_to_add = Vec::new();
109109
let mut roles_to_remove = Vec::new();
110110

111-
let bot_role = RoleId(libavacado::CONFIG.roles.bot_developer);
112-
let certified_role = RoleId(libavacado::CONFIG.roles.certified_developer);
111+
let bot_role = RoleId(config::CONFIG.roles.bot_developer);
112+
let certified_role = RoleId(config::CONFIG.roles.certified_developer);
113113

114114
if certified {
115115
ctx.say("You are the owner/additional owner of a certified bot! Giving you certified role")

bot/src/_checks.rs renamed to bot/src/checks.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
use crate::config;
2+
13
type Error = crate::Error;
24
type Context<'a> = crate::Context<'a>;
35

46
/// Check for main_server
57
pub async fn main_server(ctx: Context<'_>) -> Result<bool, Error> {
68
let in_main_server = match ctx.guild_id() {
7-
Some(guild_id) => guild_id.0 == libavacado::CONFIG.servers.main,
9+
Some(guild_id) => guild_id.0 == config::CONFIG.servers.main,
810
None => false,
911
};
1012

@@ -14,7 +16,7 @@ pub async fn main_server(ctx: Context<'_>) -> Result<bool, Error> {
1416
/// Check for staff_server
1517
pub async fn staff_server(ctx: Context<'_>) -> Result<bool, Error> {
1618
let in_staff_server = match ctx.guild_id() {
17-
Some(guild_id) => guild_id.0 == libavacado::CONFIG.servers.staff,
19+
Some(guild_id) => guild_id.0 == config::CONFIG.servers.staff,
1820
None => false,
1921
};
2022

@@ -24,7 +26,7 @@ pub async fn staff_server(ctx: Context<'_>) -> Result<bool, Error> {
2426
/// Check for staff_server
2527
pub async fn testing_server(ctx: Context<'_>) -> Result<bool, Error> {
2628
let in_testing_server = match ctx.guild_id() {
27-
Some(guild_id) => guild_id.0 == libavacado::CONFIG.servers.testing,
29+
Some(guild_id) => guild_id.0 == config::CONFIG.servers.testing,
2830
None => false,
2931
};
3032

libavacado/src/env.rs renamed to bot/src/config.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
use serde::{Deserialize, Serialize};
22
use serde_yaml;
33
use std::{fs::File, io::Write, num::NonZeroU64};
4+
use once_cell::sync::Lazy;
5+
6+
/// Global config object
7+
pub static CONFIG: Lazy<Config> = Lazy::new(|| Config::load());
48

59
#[derive(Serialize, Deserialize)]
610
pub struct Servers {
@@ -138,10 +142,10 @@ impl Config {
138142
match file {
139143
Ok(file) => {
140144
// Parse config.yaml
141-
let config: Config = serde_yaml::from_reader(file).unwrap();
145+
let cfg: Config = serde_yaml::from_reader(file).unwrap();
142146

143147
// Return config
144-
config
148+
cfg
145149
}
146150
Err(e) => {
147151
// Print error

0 commit comments

Comments
 (0)