forked from Skynet/discord-bot
feat: fmt and clippy
This commit is contained in:
parent
9b42187b22
commit
802f3fce59
2 changed files with 245 additions and 224 deletions
9
.rustfmt.toml
Normal file
9
.rustfmt.toml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
max_width = 150
|
||||||
|
single_line_if_else_max_width = 100
|
||||||
|
chain_width = 100
|
||||||
|
fn_params_layout = "Compressed"
|
||||||
|
#control_brace_style = "ClosingNextLine"
|
||||||
|
#brace_style = "PreferSameLine"
|
||||||
|
struct_lit_width = 0
|
||||||
|
tab_spaces = 2
|
||||||
|
use_small_heuristics = "Max"
|
38
src/main.rs
38
src/main.rs
|
@ -1,14 +1,25 @@
|
||||||
use std::env;
|
|
||||||
use std::sync::Arc;
|
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
|
||||||
use std::time::Duration;
|
|
||||||
use dotenvy::dotenv;
|
use dotenvy::dotenv;
|
||||||
use serenity::async_trait;
|
use serenity::{
|
||||||
use serenity::model::gateway::{GatewayIntents, Ready};
|
async_trait,
|
||||||
use serenity::model::guild::Member;
|
client::{Context, EventHandler},
|
||||||
use serenity::model::id::GuildId;
|
model::{
|
||||||
use serenity::prelude::*;
|
gateway::{GatewayIntents, Ready},
|
||||||
use serenity::model::prelude::RoleId;
|
guild::Member,
|
||||||
|
id::GuildId,
|
||||||
|
prelude::RoleId,
|
||||||
|
},
|
||||||
|
prelude::TypeMapKey,
|
||||||
|
Client,
|
||||||
|
};
|
||||||
|
use std::{
|
||||||
|
env,
|
||||||
|
sync::{
|
||||||
|
atomic::{AtomicBool, Ordering},
|
||||||
|
Arc,
|
||||||
|
},
|
||||||
|
time::Duration,
|
||||||
|
};
|
||||||
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
struct Handler {
|
struct Handler {
|
||||||
is_loop_running: AtomicBool,
|
is_loop_running: AtomicBool,
|
||||||
|
@ -193,7 +204,9 @@ 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 { is_loop_running: AtomicBool::new(false)})
|
.event_handler(Handler {
|
||||||
|
is_loop_running: AtomicBool::new(false),
|
||||||
|
})
|
||||||
.await
|
.await
|
||||||
.expect("Error creating client");
|
.expect("Error creating client");
|
||||||
|
|
||||||
|
@ -206,10 +219,10 @@ async fn main() {
|
||||||
// a list of all current members
|
// a list of all current members
|
||||||
data.insert::<Members>(Arc::new(RwLock::new(vec![])));
|
data.insert::<Members>(Arc::new(RwLock::new(vec![])));
|
||||||
|
|
||||||
|
// make config available top all, strangely its easier to keep it in a shared lock state.
|
||||||
data.insert::<Config>(Arc::new(RwLock::new(config)));
|
data.insert::<Config>(Arc::new(RwLock::new(config)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Finally, start a single shard, and start listening to events.
|
// Finally, start a single shard, and start listening to events.
|
||||||
//
|
//
|
||||||
// Shards will automatically attempt to reconnect, and will perform
|
// Shards will automatically attempt to reconnect, and will perform
|
||||||
|
@ -219,7 +232,6 @@ async fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
server: GuildId,
|
server: GuildId,
|
||||||
member_role_current: RoleId,
|
member_role_current: RoleId,
|
||||||
|
|
Loading…
Reference in a new issue