feat: add caching to everything, should make all member interacts faster
This commit is contained in:
parent
3abbb8d485
commit
e901f3ed74
6 changed files with 40 additions and 4 deletions
|
@ -1,3 +1,4 @@
|
|||
use serenity::all::{ChunkGuildFilter, GuildId};
|
||||
use serenity::{
|
||||
async_trait,
|
||||
client::{Context, EventHandler},
|
||||
|
@ -23,6 +24,7 @@ async fn main() {
|
|||
// Build our client.
|
||||
let mut client = Client::builder(&config.discord_token, intents)
|
||||
.event_handler(Handler {})
|
||||
.cache_settings(serenity::cache::Settings::default())
|
||||
.await
|
||||
.expect("Error creating client");
|
||||
|
||||
|
@ -41,6 +43,13 @@ async fn main() {
|
|||
struct Handler;
|
||||
#[async_trait]
|
||||
impl EventHandler for Handler {
|
||||
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);
|
||||
}
|
||||
println!("Cache built successfully!");
|
||||
}
|
||||
|
||||
async fn ready(&self, ctx: Context, ready: Ready) {
|
||||
let ctx = Arc::new(ctx);
|
||||
println!("{} is connected!", ready.user.name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue