Remove top.gg

This commit is contained in:
jude 2023-10-21 23:52:08 +01:00
parent cee578eaf1
commit bec92177cb

View File

@ -1,11 +1,8 @@
use std::{collections::HashMap, env};
use poise::serenity_prelude::{ use poise::serenity_prelude::{
model::{ model::{
application::interaction::{Interaction, InteractionResponseType}, application::interaction::{Interaction, InteractionResponseType},
channel::Channel, channel::Channel,
}, },
utils::shard_id,
ActionRowComponent, Activity, Context, CreateActionRow, CreateComponents, ActionRowComponent, Activity, Context, CreateActionRow, CreateComponents,
}; };
@ -25,46 +22,6 @@ pub async fn listener(ctx: &Context, event: &poise::Event<'_>, data: &Data) -> R
poise::Event::Ready { .. } => { poise::Event::Ready { .. } => {
ctx.set_activity(Activity::watching("for /play")).await; ctx.set_activity(Activity::watching("for /play")).await;
} }
poise::Event::GuildCreate { guild, is_new, .. } => {
if *is_new {
if let Ok(token) = env::var("DISCORDBOTS_TOKEN") {
let shard_count = ctx.cache.shard_count();
let current_shard_id = shard_id(guild.id.as_u64().to_owned(), shard_count);
let guild_count = ctx
.cache
.guilds()
.iter()
.filter(|g| {
shard_id(g.as_u64().to_owned(), shard_count) == current_shard_id
})
.count() as u64;
let mut hm = HashMap::new();
hm.insert("server_count", guild_count);
hm.insert("shard_id", current_shard_id);
hm.insert("shard_count", shard_count);
let response = data
.http
.post(
format!(
"https://top.gg/api/bots/{}/stats",
ctx.cache.current_user_id().as_u64()
)
.as_str(),
)
.header("Authorization", token)
.json(&hm)
.send()
.await;
if let Err(res) = response {
println!("DiscordBots Response: {:?}", res);
}
}
}
}
poise::Event::VoiceStateUpdate { old, new, .. } => { poise::Event::VoiceStateUpdate { old, new, .. } => {
if let Some(past_state) = old { if let Some(past_state) = old {
if let (Some(guild_id), None) = (past_state.guild_id, new.channel_id) { if let (Some(guild_id), None) = (past_state.guild_id, new.channel_id) {