fmt: clippy and nightly fmt
This commit is contained in:
parent
57d4947edf
commit
9d409e3692
20 changed files with 194 additions and 143 deletions
|
@ -7,4 +7,4 @@ fn_params_layout = "Compressed"
|
||||||
struct_lit_width = 0
|
struct_lit_width = 0
|
||||||
tab_spaces = 2
|
tab_spaces = 2
|
||||||
use_small_heuristics = "Max"
|
use_small_heuristics = "Max"
|
||||||
#imports_granularity="Crate"
|
imports_granularity = "Crate"
|
|
@ -1,14 +1,17 @@
|
||||||
use serenity::all::{ChunkGuildFilter, GuildId, GuildMembersChunkEvent};
|
|
||||||
use serenity::{
|
use serenity::{
|
||||||
|
all::{ChunkGuildFilter, GuildId, GuildMembersChunkEvent},
|
||||||
async_trait,
|
async_trait,
|
||||||
client::{Context, EventHandler},
|
client::{Context, EventHandler},
|
||||||
model::gateway::{GatewayIntents, Ready},
|
model::gateway::GatewayIntents,
|
||||||
Client,
|
Client,
|
||||||
};
|
};
|
||||||
use skynet_discord_bot::common::database::{db_init, DataBase};
|
use skynet_discord_bot::{
|
||||||
|
common::{
|
||||||
use skynet_discord_bot::common::set_roles::committee::db_roles_get;
|
database::{db_init, DataBase},
|
||||||
use skynet_discord_bot::{get_config, Config};
|
set_roles::committee::db_roles_get,
|
||||||
|
},
|
||||||
|
get_config, Config,
|
||||||
|
};
|
||||||
use sqlx::{Pool, Sqlite};
|
use sqlx::{Pool, Sqlite};
|
||||||
use std::{process, sync::Arc};
|
use std::{process, sync::Arc};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
use serenity::all::{ChunkGuildFilter, GuildId, GuildMembersChunkEvent};
|
|
||||||
use serenity::{
|
use serenity::{
|
||||||
|
all::{ChunkGuildFilter, GuildId, GuildMembersChunkEvent},
|
||||||
async_trait,
|
async_trait,
|
||||||
client::{Context, EventHandler},
|
client::{Context, EventHandler},
|
||||||
model::gateway::{GatewayIntents, Ready},
|
model::gateway::GatewayIntents,
|
||||||
Client,
|
Client,
|
||||||
};
|
};
|
||||||
use skynet_discord_bot::common::database::{db_init, DataBase};
|
use skynet_discord_bot::{
|
||||||
use skynet_discord_bot::common::set_roles::committee;
|
common::{
|
||||||
use skynet_discord_bot::{get_config, Config};
|
database::{db_init, DataBase},
|
||||||
|
set_roles::committee,
|
||||||
|
},
|
||||||
|
get_config, Config,
|
||||||
|
};
|
||||||
use std::{process, sync::Arc};
|
use std::{process, sync::Arc};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
use serenity::all::{ChunkGuildFilter, GuildId};
|
|
||||||
use serenity::{
|
use serenity::{
|
||||||
async_trait,
|
async_trait,
|
||||||
client::{Context, EventHandler},
|
client::{Context, EventHandler},
|
||||||
model::gateway::{GatewayIntents, Ready},
|
model::gateway::{GatewayIntents, Ready},
|
||||||
Client,
|
Client,
|
||||||
};
|
};
|
||||||
use skynet_discord_bot::common::database::{db_init, DataBase};
|
use skynet_discord_bot::{
|
||||||
use skynet_discord_bot::common::wolves::cns::get_wolves;
|
common::{
|
||||||
use skynet_discord_bot::common::wolves::committees::get_cns;
|
database::{db_init, DataBase},
|
||||||
use skynet_discord_bot::{get_config, Config};
|
wolves::{cns::get_wolves, committees::get_cns},
|
||||||
|
},
|
||||||
|
get_config, Config,
|
||||||
|
};
|
||||||
use std::{process, sync::Arc};
|
use std::{process, sync::Arc};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
use skynet_discord_bot::common::database::db_init;
|
use skynet_discord_bot::{
|
||||||
use skynet_discord_bot::common::minecraft::{get_minecraft_config, update_server, whitelist_wipe};
|
common::{
|
||||||
use skynet_discord_bot::get_config;
|
database::db_init,
|
||||||
|
minecraft::{get_minecraft_config, update_server, whitelist_wipe},
|
||||||
|
},
|
||||||
|
get_config,
|
||||||
|
};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
use serenity::all::{ChunkGuildFilter, GuildId};
|
|
||||||
use serenity::{
|
use serenity::{
|
||||||
async_trait,
|
async_trait,
|
||||||
client::{Context, EventHandler},
|
client::{Context, EventHandler},
|
||||||
model::gateway::{GatewayIntents, Ready},
|
model::gateway::{GatewayIntents, Ready},
|
||||||
Client,
|
Client,
|
||||||
};
|
};
|
||||||
use skynet_discord_bot::common::server_icon::{get_config_icons, update_icon};
|
|
||||||
use skynet_discord_bot::{
|
use skynet_discord_bot::{
|
||||||
common::database::{db_init, DataBase},
|
common::{
|
||||||
|
database::{db_init, DataBase},
|
||||||
|
server_icon::{get_config_icons, update_icon},
|
||||||
|
},
|
||||||
get_config, Config,
|
get_config, Config,
|
||||||
};
|
};
|
||||||
use std::{process, sync::Arc};
|
use std::{process, sync::Arc};
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
use serenity::all::{ChunkGuildFilter, GuildId, GuildMembersChunkEvent};
|
|
||||||
use serenity::{
|
use serenity::{
|
||||||
|
all::{ChunkGuildFilter, GuildId, GuildMembersChunkEvent},
|
||||||
async_trait,
|
async_trait,
|
||||||
client::{Context, EventHandler},
|
client::{Context, EventHandler},
|
||||||
model::gateway::{GatewayIntents, Ready},
|
model::gateway::GatewayIntents,
|
||||||
Client,
|
Client,
|
||||||
};
|
};
|
||||||
use skynet_discord_bot::common::database::{db_init, get_server_config_bulk, DataBase};
|
use skynet_discord_bot::{
|
||||||
use skynet_discord_bot::common::set_roles::normal;
|
common::{
|
||||||
use skynet_discord_bot::{get_config, Config};
|
database::{db_init, get_server_config_bulk, DataBase},
|
||||||
|
set_roles::normal,
|
||||||
|
},
|
||||||
|
get_config, Config,
|
||||||
|
};
|
||||||
use std::{process, sync::Arc};
|
use std::{process, sync::Arc};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
|
@ -70,6 +74,6 @@ async fn check_bulk(ctx: &Context) {
|
||||||
let db = db_lock.read().await;
|
let db = db_lock.read().await;
|
||||||
|
|
||||||
for server_config in get_server_config_bulk(&db).await {
|
for server_config in get_server_config_bulk(&db).await {
|
||||||
normal::update_server(&ctx, &server_config, &[], &[]).await;
|
normal::update_server(ctx, &server_config, &[], &[]).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
use serenity::all::{CommandDataOption, CommandDataOptionValue, CommandInteraction};
|
use serenity::{
|
||||||
use serenity::client::Context;
|
all::{CommandDataOption, CommandDataOptionValue, CommandInteraction},
|
||||||
use skynet_discord_bot::common::database::{get_server_config, DataBase, Servers};
|
client::Context,
|
||||||
use skynet_discord_bot::common::set_roles::normal::update_server;
|
};
|
||||||
use skynet_discord_bot::common::wolves::cns::get_wolves;
|
use skynet_discord_bot::common::{
|
||||||
|
database::{get_server_config, DataBase, Servers},
|
||||||
|
set_roles::normal::update_server,
|
||||||
|
wolves::cns::get_wolves,
|
||||||
|
};
|
||||||
use sqlx::{Error, Pool, Sqlite};
|
use sqlx::{Error, Pool, Sqlite};
|
||||||
|
|
||||||
pub async fn run(command: &CommandInteraction, ctx: &Context) -> String {
|
pub async fn run(command: &CommandInteraction, ctx: &Context) -> String {
|
||||||
|
|
|
@ -5,8 +5,7 @@ pub mod committee {
|
||||||
use serenity::all::{
|
use serenity::all::{
|
||||||
CommandDataOption, CommandDataOptionValue, CommandInteraction, CommandOptionType, Context, CreateCommand, CreateCommandOption,
|
CommandDataOption, CommandDataOptionValue, CommandInteraction, CommandOptionType, Context, CreateCommand, CreateCommandOption,
|
||||||
};
|
};
|
||||||
use skynet_discord_bot::common::database::DataBase;
|
use skynet_discord_bot::common::{database::DataBase, set_roles::committee::db_roles_get};
|
||||||
use skynet_discord_bot::common::set_roles::committee::db_roles_get;
|
|
||||||
|
|
||||||
pub async fn run(command: &CommandInteraction, ctx: &Context) -> String {
|
pub async fn run(command: &CommandInteraction, ctx: &Context) -> String {
|
||||||
let sub_options = if let Some(CommandDataOption {
|
let sub_options = if let Some(CommandDataOption {
|
||||||
|
@ -85,9 +84,13 @@ pub mod servers {
|
||||||
// get the list of all the current clubs/socs
|
// get the list of all the current clubs/socs
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serenity::all::{CommandInteraction, CommandOptionType, Context, CreateCommand, CreateCommandOption};
|
use serenity::all::{CommandInteraction, CommandOptionType, Context, CreateCommand, CreateCommandOption};
|
||||||
use skynet_discord_bot::common::database::{get_server_config_bulk, DataBase};
|
use skynet_discord_bot::{
|
||||||
use skynet_discord_bot::common::set_roles::committee::get_committees;
|
common::{
|
||||||
use skynet_discord_bot::get_now_iso;
|
database::{get_server_config_bulk, DataBase},
|
||||||
|
set_roles::committee::get_committees,
|
||||||
|
},
|
||||||
|
get_now_iso,
|
||||||
|
};
|
||||||
use sqlx::{Pool, Sqlite};
|
use sqlx::{Pool, Sqlite};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,17 @@ pub(crate) mod user {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::commands::wolves::link::get_server_member_discord;
|
use crate::commands::wolves::link::get_server_member_discord;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serenity::all::{CommandDataOption, CommandDataOptionValue, CommandInteraction};
|
use serenity::{
|
||||||
use serenity::model::id::UserId;
|
all::{CommandDataOption, CommandDataOptionValue, CommandInteraction},
|
||||||
use skynet_discord_bot::common::database::Wolves;
|
model::id::UserId,
|
||||||
use skynet_discord_bot::common::minecraft::{whitelist_update, Minecraft};
|
};
|
||||||
use skynet_discord_bot::Config;
|
use skynet_discord_bot::{
|
||||||
|
common::{
|
||||||
|
database::Wolves,
|
||||||
|
minecraft::{whitelist_update, Minecraft},
|
||||||
|
},
|
||||||
|
Config,
|
||||||
|
};
|
||||||
use sqlx::Error;
|
use sqlx::Error;
|
||||||
|
|
||||||
pub async fn run(command: &CommandInteraction, ctx: &Context) -> String {
|
pub async fn run(command: &CommandInteraction, ctx: &Context) -> String {
|
||||||
|
@ -185,14 +191,17 @@ pub(crate) mod server {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
pub(crate) mod add {
|
pub(crate) mod add {
|
||||||
use serenity::all::{CommandDataOption, CommandDataOptionValue, CommandInteraction, CommandOptionType, CreateCommand, CreateCommandOption};
|
use serenity::{
|
||||||
use serenity::model::id::GuildId;
|
all::{CommandDataOption, CommandDataOptionValue, CommandInteraction, CommandOptionType, CreateCommand, CreateCommandOption},
|
||||||
|
model::id::GuildId,
|
||||||
|
};
|
||||||
use sqlx::Error;
|
use sqlx::Error;
|
||||||
// this is to managfe the server side of commands related to minecraft
|
// this is to managfe the server side of commands related to minecraft
|
||||||
use super::*;
|
use super::*;
|
||||||
use skynet_discord_bot::common::minecraft::update_server;
|
use skynet_discord_bot::{
|
||||||
use skynet_discord_bot::common::minecraft::Minecraft;
|
common::minecraft::{update_server, Minecraft},
|
||||||
use skynet_discord_bot::Config;
|
Config,
|
||||||
|
};
|
||||||
|
|
||||||
pub fn register() -> CreateCommand {
|
pub fn register() -> CreateCommand {
|
||||||
CreateCommand::new("minecraft_add")
|
CreateCommand::new("minecraft_add")
|
||||||
|
@ -260,12 +269,14 @@ pub(crate) mod server {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) mod list {
|
pub(crate) mod list {
|
||||||
use serenity::all::CommandInteraction;
|
use serenity::{all::CommandInteraction, builder::CreateCommand, client::Context};
|
||||||
use serenity::builder::CreateCommand;
|
use skynet_discord_bot::{
|
||||||
use serenity::client::Context;
|
common::{
|
||||||
use skynet_discord_bot::common::database::DataBase;
|
database::DataBase,
|
||||||
use skynet_discord_bot::common::minecraft::{get_minecraft_config_server, server_information};
|
minecraft::{get_minecraft_config_server, server_information},
|
||||||
use skynet_discord_bot::Config;
|
},
|
||||||
|
Config,
|
||||||
|
};
|
||||||
|
|
||||||
pub fn register() -> CreateCommand {
|
pub fn register() -> CreateCommand {
|
||||||
CreateCommand::new("minecraft_list")
|
CreateCommand::new("minecraft_list")
|
||||||
|
@ -320,12 +331,13 @@ pub(crate) mod server {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) mod delete {
|
pub(crate) mod delete {
|
||||||
use serenity::all::{CommandDataOption, CommandDataOptionValue, CommandInteraction, CommandOptionType, CreateCommandOption};
|
use serenity::{
|
||||||
use serenity::builder::CreateCommand;
|
all::{CommandDataOption, CommandDataOptionValue, CommandInteraction, CommandOptionType, CreateCommandOption},
|
||||||
use serenity::client::Context;
|
builder::CreateCommand,
|
||||||
use serenity::model::id::GuildId;
|
client::Context,
|
||||||
use skynet_discord_bot::common::database::DataBase;
|
model::id::GuildId,
|
||||||
use skynet_discord_bot::common::minecraft::Minecraft;
|
};
|
||||||
|
use skynet_discord_bot::common::{database::DataBase, minecraft::Minecraft};
|
||||||
use sqlx::{Error, Pool, Sqlite};
|
use sqlx::{Error, Pool, Sqlite};
|
||||||
|
|
||||||
pub fn register() -> CreateCommand {
|
pub fn register() -> CreateCommand {
|
||||||
|
|
|
@ -142,8 +142,7 @@ pub mod edit {
|
||||||
pub mod list {}
|
pub mod list {}
|
||||||
|
|
||||||
pub mod tools {
|
pub mod tools {
|
||||||
use serenity::client::Context;
|
use serenity::{client::Context, model::guild::Member};
|
||||||
use serenity::model::guild::Member;
|
|
||||||
use skynet_discord_bot::common::database::RoleAdder;
|
use skynet_discord_bot::common::database::RoleAdder;
|
||||||
use sqlx::{Pool, Sqlite};
|
use sqlx::{Pool, Sqlite};
|
||||||
|
|
||||||
|
|
|
@ -113,8 +113,10 @@ pub(crate) mod user {
|
||||||
|
|
||||||
pub(crate) mod festival {
|
pub(crate) mod festival {
|
||||||
use serenity::all::{CommandInteraction, Context};
|
use serenity::all::{CommandInteraction, Context};
|
||||||
use skynet_discord_bot::common::server_icon::{get_config_icons, update_icon::get_festival};
|
use skynet_discord_bot::{
|
||||||
use skynet_discord_bot::Config;
|
common::server_icon::{get_config_icons, update_icon::get_festival},
|
||||||
|
Config,
|
||||||
|
};
|
||||||
|
|
||||||
// use this to return what current festivals are active?
|
// use this to return what current festivals are active?
|
||||||
pub async fn run(_command: &CommandInteraction, ctx: &Context) -> String {
|
pub async fn run(_command: &CommandInteraction, ctx: &Context) -> String {
|
||||||
|
|
|
@ -4,11 +4,16 @@ use lettre::{
|
||||||
Message, SmtpTransport, Transport,
|
Message, SmtpTransport, Transport,
|
||||||
};
|
};
|
||||||
use maud::html;
|
use maud::html;
|
||||||
use serenity::all::CommandOptionType;
|
use serenity::{
|
||||||
use serenity::builder::CreateCommandOption;
|
all::CommandOptionType,
|
||||||
use serenity::{builder::CreateCommand, client::Context, model::id::UserId};
|
builder::{CreateCommand, CreateCommandOption},
|
||||||
use skynet_discord_bot::common::database::{DataBase, Wolves, WolvesVerify};
|
client::Context,
|
||||||
use skynet_discord_bot::{get_now_iso, random_string, Config};
|
model::id::UserId,
|
||||||
|
};
|
||||||
|
use skynet_discord_bot::{
|
||||||
|
common::database::{DataBase, Wolves, WolvesVerify},
|
||||||
|
get_now_iso, random_string, Config,
|
||||||
|
};
|
||||||
use sqlx::{Pool, Sqlite};
|
use sqlx::{Pool, Sqlite};
|
||||||
|
|
||||||
pub mod link {
|
pub mod link {
|
||||||
|
@ -298,11 +303,14 @@ pub mod link_docs {
|
||||||
pub mod verify {
|
pub mod verify {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::commands::wolves::link::{db_pending_clear_expired, get_server_member_discord, get_verify_from_db};
|
use crate::commands::wolves::link::{db_pending_clear_expired, get_server_member_discord, get_verify_from_db};
|
||||||
use serenity::all::{CommandDataOption, CommandDataOptionValue, CommandInteraction};
|
use serenity::{
|
||||||
use serenity::model::user::User;
|
all::{CommandDataOption, CommandDataOptionValue, CommandInteraction},
|
||||||
use skynet_discord_bot::common::database::get_server_config;
|
model::user::User,
|
||||||
use skynet_discord_bot::common::database::{ServerMembersWolves, Servers};
|
};
|
||||||
use skynet_discord_bot::common::wolves::committees::Committees;
|
use skynet_discord_bot::common::{
|
||||||
|
database::{get_server_config, ServerMembersWolves, Servers},
|
||||||
|
wolves::committees::Committees,
|
||||||
|
};
|
||||||
use sqlx::Error;
|
use sqlx::Error;
|
||||||
|
|
||||||
pub async fn run(command: &CommandInteraction, ctx: &Context) -> String {
|
pub async fn run(command: &CommandInteraction, ctx: &Context) -> String {
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
use crate::Config;
|
use crate::Config;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serenity::model::guild;
|
use serenity::{
|
||||||
use serenity::model::id::{ChannelId, GuildId, RoleId, UserId};
|
model::{
|
||||||
use serenity::prelude::TypeMapKey;
|
guild,
|
||||||
use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions, SqliteRow};
|
id::{ChannelId, GuildId, RoleId, UserId},
|
||||||
use sqlx::{Error, FromRow, Pool, Row, Sqlite};
|
},
|
||||||
use std::str::FromStr;
|
prelude::TypeMapKey,
|
||||||
use std::sync::Arc;
|
};
|
||||||
|
use sqlx::{
|
||||||
|
sqlite::{SqliteConnectOptions, SqlitePoolOptions, SqliteRow},
|
||||||
|
Error, FromRow, Pool, Row, Sqlite,
|
||||||
|
};
|
||||||
|
use std::{str::FromStr, sync::Arc};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
pub struct DataBase;
|
pub struct DataBase;
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
use crate::common::set_roles::normal::get_server_member_bulk;
|
use crate::{common::set_roles::normal::get_server_member_bulk, Config};
|
||||||
use crate::Config;
|
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||||
use serde::de::DeserializeOwned;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use serenity::model::id::GuildId;
|
use serenity::model::id::GuildId;
|
||||||
use sqlx::sqlite::SqliteRow;
|
use sqlx::{sqlite::SqliteRow, Error, FromRow, Pool, Row, Sqlite};
|
||||||
use sqlx::{Error, FromRow, Pool, Row, Sqlite};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct Minecraft {
|
pub struct Minecraft {
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
// this code is taken from https://github.com/MCorange99/svg2colored-png/tree/main
|
// 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 younked it from here.
|
||||||
|
|
||||||
use std::ffi::OsStr;
|
use std::{
|
||||||
use std::path::{Path, PathBuf};
|
ffi::OsStr,
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
};
|
||||||
|
|
||||||
// use clap::builder::OsStr;
|
// use clap::builder::OsStr;
|
||||||
use color_eyre::{eyre::bail, Result};
|
use color_eyre::{eyre::bail, Result};
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
pub mod normal {
|
pub mod normal {
|
||||||
use crate::common::database::{DataBase, ServerMembersWolves, Servers, Wolves};
|
use crate::{
|
||||||
use crate::get_now_iso;
|
common::database::{DataBase, ServerMembersWolves, Servers, Wolves},
|
||||||
use serenity::client::Context;
|
get_now_iso,
|
||||||
use serenity::model::id::{GuildId, RoleId, UserId};
|
};
|
||||||
|
use serenity::{
|
||||||
|
client::Context,
|
||||||
|
model::id::{GuildId, RoleId, UserId},
|
||||||
|
};
|
||||||
use sqlx::{Pool, Sqlite};
|
use sqlx::{Pool, Sqlite};
|
||||||
|
|
||||||
struct RolesChange {
|
struct RolesChange {
|
||||||
|
@ -152,21 +156,22 @@ pub mod normal {
|
||||||
|
|
||||||
// for updating committee members
|
// for updating committee members
|
||||||
pub mod committee {
|
pub mod committee {
|
||||||
use crate::common::database::{get_channel_from_row, get_role_from_row, DataBase, Wolves};
|
use crate::{
|
||||||
use crate::common::wolves::committees::Committees;
|
common::{
|
||||||
use crate::Config;
|
database::{get_channel_from_row, get_role_from_row, DataBase, Wolves},
|
||||||
|
wolves::committees::Committees,
|
||||||
|
},
|
||||||
|
Config,
|
||||||
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serenity::all::EditRole;
|
use serenity::{
|
||||||
use serenity::builder::CreateChannel;
|
all::EditRole,
|
||||||
use serenity::client::Context;
|
builder::CreateChannel,
|
||||||
use serenity::model::channel::ChannelType;
|
client::Context,
|
||||||
use serenity::model::guild::Member;
|
model::{channel::ChannelType, guild::Member, id::ChannelId, prelude::RoleId},
|
||||||
use serenity::model::id::ChannelId;
|
};
|
||||||
use serenity::model::prelude::RoleId;
|
use sqlx::{sqlite::SqliteRow, Error, FromRow, Pool, Row, Sqlite};
|
||||||
use sqlx::sqlite::SqliteRow;
|
|
||||||
use sqlx::{Error, FromRow, Pool, Row, Sqlite};
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
pub async fn check_committee(ctx: &Context) {
|
pub async fn check_committee(ctx: &Context) {
|
||||||
let db_lock = {
|
let db_lock = {
|
||||||
|
@ -187,7 +192,7 @@ pub mod committee {
|
||||||
// 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 teh server
|
||||||
let mut members = server.members(&ctx, None, None).await.unwrap_or_default();
|
let mut members = server.members(&ctx, None, None).await.unwrap_or_default();
|
||||||
|
|
||||||
update_committees(&db, &ctx, &config_global, &mut members).await;
|
update_committees(&db, ctx, &config_global, &mut members).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -342,11 +347,11 @@ pub mod committee {
|
||||||
for role in &roles_current {
|
for role in &roles_current {
|
||||||
roles_current_id.push(role.id.to_owned());
|
roles_current_id.push(role.id.to_owned());
|
||||||
if !roles_required.contains(&role.id) {
|
if !roles_required.contains(&role.id) {
|
||||||
if role.id == committee_member {
|
if role.id == committee_member && on_committee {
|
||||||
if !on_committee {
|
continue;
|
||||||
roles_rem.push(role.id.to_owned());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
roles_rem.push(role.id.to_owned());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,11 +48,14 @@ async fn add_users_wolves(db: &Pool<Sqlite>, user: &WolvesResultUserMin) {
|
||||||
This is getting data for Clubs and Socs
|
This is getting data for Clubs and Socs
|
||||||
*/
|
*/
|
||||||
pub mod cns {
|
pub mod cns {
|
||||||
use crate::common::database::{get_server_config_bulk, DataBase, ServerMembers, ServerMembersWolves, Servers};
|
use crate::{
|
||||||
use crate::common::wolves::{add_users_wolves, WolvesResultUserMin};
|
common::{
|
||||||
use crate::Config;
|
database::{get_server_config_bulk, DataBase, ServerMembers, ServerMembersWolves, Servers},
|
||||||
use serenity::client::Context;
|
wolves::{add_users_wolves, WolvesResultUserMin},
|
||||||
use serenity::model::id::GuildId;
|
},
|
||||||
|
Config,
|
||||||
|
};
|
||||||
|
use serenity::{client::Context, model::id::GuildId};
|
||||||
use sqlx::{Pool, Sqlite};
|
use sqlx::{Pool, Sqlite};
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
@ -191,8 +194,7 @@ pub mod cns {
|
||||||
Get and store the data on C&S committees
|
Get and store the data on C&S committees
|
||||||
*/
|
*/
|
||||||
pub mod committees {
|
pub mod committees {
|
||||||
use crate::common::database::DataBase;
|
use crate::{common::database::DataBase, Config};
|
||||||
use crate::Config;
|
|
||||||
use serenity::client::Context;
|
use serenity::client::Context;
|
||||||
use sqlx::{Pool, Sqlite};
|
use sqlx::{Pool, Sqlite};
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,10 @@ pub mod common;
|
||||||
use chrono::{Datelike, SecondsFormat, Utc};
|
use chrono::{Datelike, SecondsFormat, Utc};
|
||||||
use dotenvy::dotenv;
|
use dotenvy::dotenv;
|
||||||
use rand::{distr::Alphanumeric, rng, Rng};
|
use rand::{distr::Alphanumeric, rng, Rng};
|
||||||
use serenity::model::id::{ChannelId, GuildId, RoleId};
|
use serenity::{
|
||||||
use serenity::prelude::TypeMapKey;
|
model::id::{ChannelId, GuildId, RoleId},
|
||||||
|
prelude::TypeMapKey,
|
||||||
|
};
|
||||||
use std::{env, sync::Arc};
|
use std::{env, sync::Arc};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
|
|
36
src/main.rs
36
src/main.rs
|
@ -1,39 +1,33 @@
|
||||||
pub mod commands;
|
pub mod commands;
|
||||||
|
|
||||||
use crate::commands::role_adder::tools::on_role_change;
|
use crate::commands::role_adder::tools::on_role_change;
|
||||||
use crate::commands::server_icon::user::current::icon::get_current_icon;
|
|
||||||
use chrono::{Days, SecondsFormat, TimeDelta, Utc};
|
|
||||||
use serenity::all::{
|
|
||||||
ActivityData, Command, CommandDataOptionValue, CreateAttachment, CreateMessage, EditInteractionResponse, GuildId, GuildMemberUpdateEvent,
|
|
||||||
GuildMembersChunkEvent, Interaction,
|
|
||||||
};
|
|
||||||
use serenity::{
|
use serenity::{
|
||||||
|
all::{Command, CommandDataOptionValue, CreateMessage, EditInteractionResponse, Interaction},
|
||||||
async_trait,
|
async_trait,
|
||||||
client::{Context, EventHandler},
|
client::{Context, EventHandler},
|
||||||
gateway::ChunkGuildFilter,
|
gateway::{ActivityData, ChunkGuildFilter},
|
||||||
model::{
|
model::{
|
||||||
|
event::GuildMemberUpdateEvent,
|
||||||
gateway::{GatewayIntents, Ready},
|
gateway::{GatewayIntents, Ready},
|
||||||
guild::Member,
|
guild::Member,
|
||||||
|
id::GuildId,
|
||||||
user::OnlineStatus,
|
user::OnlineStatus,
|
||||||
},
|
},
|
||||||
Client,
|
Client,
|
||||||
};
|
};
|
||||||
use skynet_discord_bot::common::database::{db_init, get_server_config, get_server_config_bulk, get_server_member, DataBase};
|
use skynet_discord_bot::{
|
||||||
use skynet_discord_bot::common::server_icon::{get_config_icons, update_icon};
|
common::{
|
||||||
use skynet_discord_bot::common::set_roles::committee::update_committees;
|
database::{db_init, get_server_config, get_server_member, DataBase},
|
||||||
use skynet_discord_bot::common::set_roles::{committee, normal};
|
set_roles::committee::update_committees,
|
||||||
use skynet_discord_bot::common::wolves::cns::get_wolves;
|
wolves::committees::Committees,
|
||||||
use skynet_discord_bot::common::wolves::committees::{get_cns, Committees};
|
},
|
||||||
use skynet_discord_bot::{get_config, Config};
|
get_config, Config,
|
||||||
|
};
|
||||||
use sqlx::{Pool, Sqlite};
|
use sqlx::{Pool, Sqlite};
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
struct Handler {
|
struct Handler;
|
||||||
is_loop_running: AtomicBool,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl EventHandler for Handler {
|
impl EventHandler for Handler {
|
||||||
|
@ -301,9 +295,7 @@ async fn main() {
|
||||||
let intents = GatewayIntents::GUILDS | GatewayIntents::GUILD_MESSAGES | GatewayIntents::MESSAGE_CONTENT | GatewayIntents::GUILD_MEMBERS;
|
let intents = GatewayIntents::GUILDS | GatewayIntents::GUILD_MESSAGES | GatewayIntents::MESSAGE_CONTENT | GatewayIntents::GUILD_MEMBERS;
|
||||||
// Build our client.
|
// Build our client.
|
||||||
let mut client = Client::builder(&config.discord_token, intents)
|
let mut client = Client::builder(&config.discord_token, intents)
|
||||||
.event_handler(Handler {
|
.event_handler(Handler)
|
||||||
is_loop_running: AtomicBool::new(false),
|
|
||||||
})
|
|
||||||
.cache_settings(serenity::cache::Settings::default())
|
.cache_settings(serenity::cache::Settings::default())
|
||||||
.await
|
.await
|
||||||
.expect("Error creating client");
|
.expect("Error creating client");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue