Feature: Add a command to get server stats
See original GitHub issueWhen a user types !stats
, a message should appear with the following data:
- total users
- total messages
- total reactions
Proposed solution for total users
// inside case 'stats' on commands.ts
const memberCount = getServerMemberCount(message.client);
export function getServerMemberCount(client: Client) {
const guildKey = process.env.DISCORD_SERVER_ID
if (!guildKey) {
console.error(`Missing env. variable DISCORD_SERVER_ID. Please configure that value.`)
return 0
}
const guild = client.guilds.cache.get(guildKey)
if (!guild) {
console.error(`The guild with the configured DISCORD_SERVER_ID env. variable doesn't exist`)
return 0
}
return guild.memberCount
}
Error handling
In case of an error getting the member count for the guild, we can return 0 or null and then don’t show that field on the final message. This is something I’d like your opinions on.
I’d also like to hear your feedback @eddiejaoude, on a better way to get the server’s guild and add a default maybe. I proposed a new env. variable in order for the bot to work for various discord servers. It just has to be configured first.
Here is the card for this feature.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
Setup - ServerStats Bot
The first thing you have to do is add the bot to your server, use the button under this text to add the...
Read more >How to Add Server Stats on Discord (2022) - YouTube
In this video, i will show you how to install and setup the StatServerBot for Discord. This handly little tool allows you display...
Read more >How To Add And Setup Server Stats Bot 2022 - YouTube
Server Stats bot is a discord bot that is used to monitor the statistics of your Discord server. It can be used to...
Read more >How to setup Discord server stats bot 2021 (mobile and pc)
In this video ill show you how to setup server stats bot for your discord server in 2021 so you can have a...
Read more >How to Display Member Count / ServerStats in Discord
In this video, you will learn how to use Statbot Statdocks to display important server stats in your discord like member count, bot...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah I do not think it is possible to get the total amount of reactions without a database. Other than looping through every message on the server which really should not be done.
I think it is waiting on me to store data in the DB - I will finish the logger tomorrow that also outputs to the
bot
channel, then I will get back to the saving of data in the DB, which will open lots of doors