Member Counter Discord Bot

import os
import discord
from discord.ext import commands
from tabulate import tabulate

# Enable all intents and specifically enable the 'members' intent
intents = discord.Intents.all()
intents.members = True

# Get the bot token from environment variables
bot_token = os.environ['BOT_TOKEN']

# Create a new bot instance with the specified command prefix and intents
bot = commands.Bot(command_prefix='!', intents=intents)

# Event that runs when the bot has connected to the server
async def on_ready():
    print(f'We have logged in as {bot.user}')

# Command that counts the total number of members, bots and members excluding bots
async def member_count(ctx):

About this template

This template is, for a Discord bot that calculates the number of members, number of bots and total number of non bot members in a server. It displays a message with the member count in a table format when triggered by the !member_count command in any channel. Additionally it tracks the member count for each role. Presents this information in a table format when triggered by the !member_count_role command. The bot needs permissions and intents to work.

Introduction to the Member Counter Discord Bot Template

Welcome to the Member Counter Discord Bot template! This template offers you a made bot that can tally up the overall number of members, bots and non bot members within a Discord server. It also keeps track of member counts per role. This bot is ideal for server admins looking to monitor their communitys growth and demographics.

Getting Started with the Template

To kick off using this template click on "Start with this Template" on Lazys platform. This will set up the template, on your Lazy Builder interface all set for customization and deployment.

Setting Up Initially

Before you start using the bot you have to create an environment, for the bot token. The bot token serves as an identifier that enables the Discord API to verify your bots identity.

1. Visit the Discord Developer Portal. Establish an application.

2. Click on the "Bot" section, Add Bot ". Confirm its creation.

3. Copy the provided bot token.

4. Return to the Lazy platform. Head over to the Environment Secrets tab.

5. Generate a secret labeled BOT_TOKEN and paste in the copied bot token as its value.

Once you've configured the environment secret your bot will be able to connect with Discord when its activated.

Testing; Trying Out The Test Feature

After configuring the environment secret click on the "Test" button within Lazy platform. This action will launch your bot without requiring any input from you.

Using The Application

Once your bot is up and running use the URL generated in Discord Developer Portal to invite it to your Discord server. Remember to provide permissions for reading messages and managing roles to ensure operation.

Upon invitation of your bot, to the server utilize these commands;


This command shows you the count of members, bots and human members, in your server.

Use !member_count_role to see how many members are in each role on your server.

Setting up the App

You don't need to do any integration steps for this template. The bot will work on your Discord server once you invite it and grant the permissions.

If you face any problems or have questions about how the bot works check out the Discord API documentation for details, on bot development and permissions.

Enjoy using your Member Counter Discord Bot!

Last published
June 15, 2024

More templates like this

PDF Data Extraction and Excel Transfer

An app for extracting name, phone number, and email data from PDF files and transferring it to Excel.


Discord Ticketbot Template

A simple Discord Ticketbot for your Discord Support Department. This Template and Bot is fully customizable but already build so that you can use it right away. You need a bot token from for your bot to work. These are the steps needed to get your token: "1. 🌐 Go to the Discord Developer Portal. 🌐\n" + "2. 🆕 Create a new application and navigate to the 'Bot' section. 🤖\n" + "3. 📋 Under the 'TOKEN' section, click 'Reset Token' to get your Discord bot token and confirm by clicking 'Yes, do it'. 🔑\n" + "4. 🤖 If your bot will have any ability to read/reply to messages, then under the 'BOT' section, enable the slider titled 'Message Content Intent' ✅" + "5. 🔐 Set the 'DISCORD_BOT_TOKEN' in the Env Secrets tab with your bot token from step 3. 🔐\n" + "For bot permissions, it's recommended to start with basic permissions and adjust as needed for your app's functionality.🚀") If you encounter any bugs, please tell Lazy to fix them and report them on the Official Lazy AI Discord to @D4vidG4merLP. Credits: @meow - the Discord bot slash command template @mrlazy.notlazy - supporting me And the Biggest Thank you. You for using this template ❤️


GPT-4 Exam Generator

This app uses GPT-4 to generate a PDF of a new exam based on an uploaded PDF of a past exam.

Member Counter Discord Bot