Fix typos
Some checks failed
/ check_lfs (pull_request) Successful in 5s
/ lint_fmt (pull_request) Failing after 14s
/ lint_clippy (pull_request) Failing after 11s
/ build (pull_request) Has been skipped

This commit is contained in:
Roman Moisieiev 2025-09-11 09:12:57 +01:00
parent 7b5626c279
commit 4b4e5cb289
16 changed files with 50 additions and 62 deletions

View file

@ -16,10 +16,10 @@ use sqlx::{Pool, Sqlite};
use std::{process, sync::Arc};
use tokio::sync::RwLock;
/// Cleanup teh Committee server
/// Cleanup the Committee server
///
/// This removes any invalid roles/channels which ay have been set up accidentally
/// DO NOT run this locally unless you have a fresh copy of teh live database handy.
/// This removes any invalid roles/channels which have been set up accidentally
/// DO NOT run this locally unless you have a fresh copy of the live database handy.
#[tokio::main]
async fn main() {
let config = get_config();
@ -96,7 +96,7 @@ async fn cleanup(db: &Pool<Sqlite>, ctx: &Context, config: &Config) {
let name = &channel.name;
let committee_tmp = committees.iter().filter(|x| &x.name_channel == name).collect::<Vec<_>>();
let committee = match committee_tmp.first() {
// if there are no committees which match then this is not a channelw e care about
// if there are no committees which match then this is not a channel we care about
None => {
continue;
}
@ -118,7 +118,7 @@ async fn cleanup(db: &Pool<Sqlite>, ctx: &Context, config: &Config) {
let name = &role.name;
let committee_tmp = committees.iter().filter(|x| &x.name_role == name).collect::<Vec<_>>();
let committee = match committee_tmp.first() {
// if there are no committees which match then this is not a channelw e care about
// if there are no committees which match then this is not a channel we care about
None => {
continue;
}

View file

@ -56,7 +56,7 @@ impl EventHandler for Handler {
// get the data for each individual club/soc
get_wolves(&ctx).await;
// get teh data for the clubs/socs committees
// get the data for the clubs/socs committees
get_cns(&ctx).await;
// finish up

View file

@ -22,7 +22,7 @@ async fn main() {
// wipe whitelist first
if !wiped.contains(&server.minecraft) {
whitelist_wipe(&server.minecraft, &config.discord_token_minecraft).await;
// add it to teh done list so its not done again
// add it to the done list so its not done again
wiped.insert(&server.minecraft);
}

View file

@ -101,7 +101,7 @@ async fn add_server(db: &Pool<Sqlite>, ctx: &Context, server: &Servers) -> Resul
.fetch_optional(db)
.await;
// if the entry does not exist already tehn do a user update
// if the entry does not exist already then do a user update
let (update, current_remove, current_role, past_remove, past_role) = match &existing {
None => (true, false, None, false, None),
Some(x) => {

View file

@ -119,7 +119,7 @@ pub mod servers {
cs.push((total, total, String::from("Skynet Network")));
cs.push((wolves_current, wolves_past, String::from("Clubs/Socs Servers")));
// treat teh committee server as its own thing
// treat the committee server as its own thing
let committee_current = get_wolves_committee(&db).await;
cs.push((committee_current, committee_current, String::from("Committee Server")));
@ -150,7 +150,7 @@ pub mod servers {
let length = line.len() + 1;
// +3 is to account for the closing fense
// +3 is to account for the closing fence
if length < (limit + 3) {
response.push(line);
limit -= length;

View file

@ -195,7 +195,7 @@ pub(crate) mod server {
model::id::GuildId,
};
use sqlx::Error;
// this is to managfe the server side of commands related to minecraft
// this is to manage the server side of commands related to minecraft
use super::*;
use skynet_discord_bot::{
common::minecraft::{update_server, Minecraft},
@ -376,7 +376,7 @@ pub(crate) mod server {
}
}
// no need to clear teh whitelist as it will be reset within 24hr anyways
// no need to clear the whitelist as it will be reset within 24hr anyways
"Removed minecraft_server info".to_string()
}

View file

@ -146,7 +146,7 @@ pub mod tools {
use sqlx::{Pool, Sqlite};
pub async fn on_role_change(db: &Pool<Sqlite>, ctx: &Context, new_data: Member) {
// check if the role changed is part of the oens for this server
// check if the role changed is part of the ones for this server
if let Ok(role_adders) = sqlx::query_as::<_, RoleAdder>(
r#"
SELECT *
@ -162,7 +162,7 @@ pub mod tools {
let mut roles_remove = vec![];
for role_adder in role_adders {
// if the user has both A dnd B give them C
// if the user has both A and B give them C
if new_data.roles.contains(&role_adder.role_a) && new_data.roles.contains(&role_adder.role_b) && !new_data.roles.contains(&role_adder.role_c)
{
roles_add.push(role_adder.role_c);

View file

@ -57,7 +57,7 @@ pub(crate) mod user {
format!("{}/src/branch/main/{}/{}", &config_toml.source.repo, &config_toml.source.directory, logo_name)
}
/// Regular users can get teh link to teh current icon
/// Regular users can get the link to the current icon
pub(crate) mod current {
use super::*;
@ -208,7 +208,7 @@ pub(crate) mod user {
let length = line.len() + 1;
// +3 is to account for the closing fense
// +3 is to account for the closing fence
if length < (limit + 3) {
response.push(line);
limit -= length;

View file

@ -76,7 +76,7 @@ pub mod link {
Some(x) => x,
};
// save teh user id and email to teh db
// save the user id and email to the db
match save_to_db_user(&db, id, email).await {
Ok(x) => x,
Err(x) => {
@ -100,7 +100,7 @@ pub mod link {
return "Email already verified".to_string();
}
// generate a auth key
// generate an auth key
let auth = random_string(20);
match send_mail(&config, &details.email, &auth, &command.user.name) {
Ok(_) => match save_to_db(&db, &details, &auth, &command.user.id).await {
@ -209,7 +209,7 @@ pub mod link {
.subject("Skynet: Link Discord to Wolves.")
.multipart(
// This is composed of two parts.
// also helps not trip spam settings (uneven number of url's
// also helps not trip spam settings (uneven number of urls)
MultiPart::alternative()
.singlepart(SinglePart::builder().header(header::ContentType::TEXT_PLAIN).body(body_text))
.singlepart(SinglePart::builder().header(header::ContentType::TEXT_HTML).body(html.into_string())),
@ -354,7 +354,7 @@ pub mod verify {
Ok(_) => {
return match set_discord(&db, &command.user.id, &details.email).await {
Ok(_) => {
// get teh right roles for the user
// get the right roles for the user
set_server_roles(&db, &command.user, ctx).await;
// check if they are a committee member, and on that server
@ -458,8 +458,8 @@ pub mod verify {
let config = config_lock.read().await;
if let Some(x) = get_server_member_discord(db, &discord.id).await {
// if they are a member of one or more committees, and in teh committee server then give the teh general committee role
// they will get teh more specific vanity role later
// if they are a member of one or more committees, and in the committee server then give the general committee role
// they will get the more specific vanity role later
if !get_committees_id(db, x.id_wolves).await.is_empty() {
let server = config.committee_server;
let committee_member = config.committee_role;
@ -497,7 +497,7 @@ pub mod unlink {
data_read.get::<DataBase>().expect("Expected Databse in TypeMap.").clone()
};
// dosent matter if there is one or not, it will be removed regardless
// Doesn't matter if there is one or not, it will be removed regardless
delete_link(&db, &command.user.id).await;
"Discord link removed".to_string()

View file

@ -24,7 +24,7 @@ impl<'r> FromRow<'r, SqliteRow> for Minecraft {
/**
loop through all members of server
get a list of folks with mc accounts that are members
and a list that arent members
and a list that aren't members
*/
pub async fn update_server(server_id: &str, db: &Pool<Sqlite>, g_id: &GuildId, config: &Config) {
let mut usernames = vec![];
@ -109,7 +109,7 @@ pub async fn whitelist_wipe(server: &str, token: &str) {
};
post(&format!("{url_base}/files/delete"), &bearer, &deletion).await;
// recreate teh file, passing in the type here so the compiler knows what type of vec it is
// recreate the file, passing in the type here so the compiler knows what type of Vec it is
post::<Vec<&str>>(&format!("{url_base}/files/write?file=%2Fwhitelist.json"), &bearer, &vec![]).await;
// reload the whitelist

View file

@ -1,5 +1,5 @@
// this code is taken from https://github.com/MCorange99/svg2colored-png/tree/main
// I was unable to figure out how to use usvg myself so younked it from here.
// I was unable to figure out how to use usvg myself so yoinked it from here.
use std::{
ffi::OsStr,
@ -7,7 +7,6 @@ use std::{
sync::Arc,
};
// use clap::builder::OsStr;
use color_eyre::{eyre::bail, Result};
#[derive(Debug, Clone)]
@ -17,7 +16,7 @@ pub struct Args {
/// Output folder where the PNG's will be placed
pub output: PathBuf,
/// Comma seperated colors that will be used in HEX Eg. 000000,ffffff
/// Comma separated colors that will be used in HEX Eg. 000000,ffffff
/// Can be like an object: black:000000,white:ffffff
pub colors: String,
@ -56,7 +55,6 @@ impl Renderer {
};
this.colors = if args.colors.contains(':') {
//? object
let obj = args.colors.split(',').map(|s| {
let mut iter = s.split(':');
let [Some(a), Some(b), None] = std::array::from_fn(|_| iter.next()) else {
@ -77,12 +75,6 @@ impl Renderer {
ColorType::Object(colors)
} else {
//? list
// let colors = args.colors.split(",").map(|s| {
// s.to_string()
// })
// .collect::<Vec<String>>();
let colors = args
.colors
.split(',')
@ -158,9 +150,6 @@ impl Renderer {
x.min(y)
};
// log::info!("Rendering {fo:?}");
//? maybe handle this and possibly throw error if its none
resvg::render(&tree, usvg::Transform::default().post_scale(scale, scale), &mut pixmap.as_mut());
pixmap.save_png(fo)?;

View file

@ -281,7 +281,7 @@ pub mod update_icon {
// check if exists
if !path_new.exists() {
// convert if it hasnt been converted already
// convert if it hasn't been converted already
match r.render(&path_local, &args) {
Ok(_) => {}
Err(_e) => {
@ -349,7 +349,7 @@ pub mod update_icon {
}
async fn logo_set(ctx: &Context, db: &Pool<Sqlite>, server: &GuildId, logo_selected: &LogoData) {
// add to teh database
// add to the database
if !logo_set_db(db, logo_selected).await {
// something went wrong
return;

View file

@ -46,7 +46,7 @@ pub mod normal {
if let Ok(x) = server.members(ctx, None, None).await {
for member in x {
// members_changed acts as an override to only deal with teh users in it
// members_changed acts as an override to only deal with the users in it
if !members_changed.is_empty() && !members_changed.contains(&member.user.id) {
continue;
}
@ -82,7 +82,7 @@ pub mod normal {
if member.roles.contains(role_current) {
roles_set.current_rem += 1;
// if theya re not a current member and have the role then remove it
// if they're not a current member and have the role then remove it
if let Err(e) = member.remove_role(ctx, role_current).await {
println!("{e:?}");
}
@ -185,14 +185,14 @@ pub mod committee {
let server = config_global.committee_server;
// because to use it to update a single user we need to pre-get the members of teh server
// because to use it to update a single user we need to pre-get the members of the server
let mut members = server.members(&ctx, None, None).await.unwrap_or_default();
update_committees(&db, ctx, &config_global, &mut members).await;
}
/**
This function can take a vec of members (or just one) and gives tehm the appropiate roles on teh committee server
This function can take a Vec of members (or just one) and gives them the appropriate roles on the committee server
*/
pub async fn update_committees(db: &Pool<Sqlite>, ctx: &Context, config: &Config, members: &mut Vec<Member>) {
let server = config.committee_server;
@ -224,11 +224,11 @@ pub mod committee {
let mut channels = server.channels(&ctx).await.unwrap_or_default();
// a map of users and the roles they are goign to be getting
// a map of users and the roles they are going to be getting
let mut users_roles = HashMap::new();
let mut re_order = false;
// we need to create roles and channels if tehy dont already exist
// we need to create roles and channels if they don't already exist
let mut category_index = 0;
let mut i = 0;
loop {
@ -294,7 +294,7 @@ pub mod committee {
// save it to the db in case of crash or error
db_role_set(db, &tmp).await;
// insert it into teh local cache
// insert it into the local cache
e.insert(tmp);
re_order = true;
@ -327,7 +327,7 @@ pub mod committee {
}
}
// now we have a map of all users that should get roles time to go through all the folks on teh server
// now we have a map of all users that should get roles time to go through all the folks on the server
for member in members {
// if member.user.id != 136522490632601600 {
// continue;
@ -363,7 +363,7 @@ pub mod committee {
let has_committee_role = roles_current_id.contains(&committee_member);
if on_committee && !has_committee_role {
// if there are committee roles then give the general purporse role
// if there are committee roles then give the general purpose role
roles_add.push(committee_member);
}
if !on_committee && has_committee_role {
@ -401,10 +401,10 @@ pub mod committee {
if re_order {
let channel_id = role.id_channel.to_owned();
if let Some(channel) = channels.get_mut(&channel_id) {
// record the position of each of teh C&S channels
// record the position of each of the C&S channels
positions.push(channel.position);
// pull out teh channel names
// pull out the channel names
channel_names.push((role.name_channel.to_owned(), channel_id));
}
}

View file

@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
use sqlx::{Pool, Sqlite};
/**
This file relates to anything that directly interacts with teh wolves API
This file relates to anything that directly interacts with the wolves API
*/
#[derive(Deserialize, Serialize, Debug)]
@ -80,7 +80,7 @@ pub mod cns {
};
let config = config_lock.read().await;
// set up teh client
// set up the client
let wolves = wolves_oxidised::Client::new(&config.wolves_url, Some(&config.wolves_api));
for server_config in get_server_config_bulk(&db).await {

View file

@ -12,7 +12,7 @@ use tokio::sync::RwLock;
#[derive(Debug)]
pub struct Config {
// manages where teh database is stored
// manages where the database is stored
pub home: String,
pub database: String,
@ -36,7 +36,7 @@ pub struct Config {
pub committee_role: RoleId,
pub committee_category: Vec<ChannelId>,
// items pertaining to compsoc only
// items pertaining to CompSoc only
pub compsoc_server: GuildId,
}
impl TypeMapKey for Config {

View file

@ -27,12 +27,11 @@ use sqlx::{Pool, Sqlite};
use std::sync::Arc;
use tokio::sync::RwLock;
// Need To Define The Stuct (Committed To Bump The Bot)
struct Handler;
#[async_trait]
impl EventHandler for Handler {
// this caches members of all servers teh bot is in
// this caches members of all servers the bot is in
async fn cache_ready(&self, ctx: Context, guilds: Vec<GuildId>) {
for guild in guilds {
ctx.shard.chunk_guild(guild, Some(2000), false, ChunkGuildFilter::None, None);
@ -113,7 +112,7 @@ Sign up on [UL Wolves]({}) and go to https://discord.com/channels/{}/{} and use
data_read.get::<DataBase>().expect("Expected Config in TypeMap.").clone()
};
// check if the role changed is part of the oens for this server
// check if the role changed is part of the ones for this server
if let Some(x) = new_data {
on_role_change(&db, &ctx, x).await;
}
@ -155,13 +154,13 @@ Sign up on [UL Wolves]({}) and go to https://discord.com/channels/{}/{} and use
}
}
// compsoc Server
// CompSoc Server
match config
.compsoc_server
.set_commands(
&ctx.http,
vec![
// commands just for the compsoc server
// commands just for the CompSoc server
commands::count::servers::register(),
commands::server_icon::user::register(),
],
@ -178,7 +177,7 @@ Sign up on [UL Wolves]({}) and go to https://discord.com/channels/{}/{} and use
async fn interaction_create(&self, ctx: Context, interaction: Interaction) {
if let Interaction::Command(command) = interaction {
let _ = command.defer_ephemeral(&ctx.http).await;
//println!("Received command interaction: {:#?}", command);
// println!("Received command interaction: {:#?}", command);
let content = match command.data.name.as_str() {
// user commands
@ -213,7 +212,7 @@ Sign up on [UL Wolves]({}) and go to https://discord.com/channels/{}/{} and use
format!("not implemented :( committee {}", x.name.as_str())
}
},
// TODO: move teh minecraft commands in here as a subgroup
// TODO: move the minecraft commands in here as a subgroup
// "link" => commands::count::servers::run(&command, &ctx).await,
&_ => format!("not implemented :( committee {}", x.name.as_str()),
},