Properly report total guild count
This commit is contained in:
parent
b8ad9e40c2
commit
1b89cfd516
@ -104,7 +104,7 @@ pub fn wc_territory(command: &str, msg: &Message) -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn wc_info(msg: &Message) -> Result<(), Error> {
|
pub fn wc_info(msg: &Message) -> Result<(), Error> {
|
||||||
let guilds = serenity::http::get_current_user()?.guilds()?.len();
|
let guilds = get_guild_count()?;
|
||||||
msg.channel_id.say(format!("Developer: Wurst#1783
|
msg.channel_id.say(format!("Developer: Wurst#1783
|
||||||
Forum thread: https://forums.wynncraft.com/threads/discord-bot.212142/
|
Forum thread: https://forums.wynncraft.com/threads/discord-bot.212142/
|
||||||
Discord: https://discord.gg/GbN7HeG
|
Discord: https://discord.gg/GbN7HeG
|
||||||
@ -114,6 +114,16 @@ Servers: {}", env!("CARGO_PKG_VERSION"), guilds))?;
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_guild_count() -> Result<usize, Error> {
|
||||||
|
let mut guilds = 0;
|
||||||
|
let mut new_guilds = serenity::http::get_guilds(&serenity::http::GuildPagination::After(GuildId(0)), 100)?;
|
||||||
|
while !new_guilds.is_empty() {
|
||||||
|
guilds += new_guilds.len();
|
||||||
|
new_guilds = serenity::http::get_guilds(&serenity::http::GuildPagination::After(new_guilds.last().unwrap().id), 100)?;
|
||||||
|
}
|
||||||
|
Ok(guilds)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn wc_help(msg: &Message) -> Result<(), Error> {
|
pub fn wc_help(msg: &Message) -> Result<(), Error> {
|
||||||
if let Err(_) = msg.author.dm(|f| f.content("Command overview: (prefix is wc!)
|
if let Err(_) = msg.author.dm(|f| f.content("Command overview: (prefix is wc!)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user