Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

technerdsdendiscordbot

This repository contains a tutorial Python Discord bot used to teach contributors how to build and run a Discord bot using discord.py.

Project Goals:

  • Provide a minimal, well-documented starter bot.
  • Teach how to create a Discord Application and Bot in the Discord Developer Portal.
  • Show contributors how to run and extend the bot locally.

What's Included

  • bot.py: Minimal bot implementation with a ping command and basic event handlers.
  • requirements.txt: Python dependency list.
  • .env.example: Example environment file showing DISCORD_TOKEN usage.
  • .gitignore: Recommended ignores for Python projects.

Prerequisites

  • Python 3.10+ installed.
  • A Discord account and a server where you can add the bot for testing.

Quick start (local)

  1. Create a virtual environment and activate it:
python -m venv .venv
source .venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Create a .env file based on .env.example and fill in your bot token:
DISCORD_TOKEN=your-bot-token-here
  1. Run the bot:
python bot.py

The bot will print a logged-in message when ready.

Discord Developer Portal — Create a Bot (step-by-step)

  1. Open the Discord Developer Portal: https://discord.com/developers/applications

  2. Click New Application, give it a name, and create the application.

  3. In the sidebar, go to Bot and click Add BotYes, do it!

  4. Under the Bot section:

    • Copy the TOKEN (click Reset Token if none exists) — this is the value for DISCORD_TOKEN in your .env file.
    • (Optional) Upload an avatar and edit the bot username.
    • Under Privileged Gateway Intents, enable Message Content Intent if you want the bot to read message content (required for some bot features). Also enable Presence Intent or Server Members Intent if you plan to use those features.
  5. Invite the bot to your server:

    • In the Developer Portal, go to OAuth2URL Generator.
    • Under Scopes, check bot and applications.commands (if you intend to add slash commands later).
    • Under Bot Permissions, select the permissions your bot needs (for the tutorial, Send Messages and Read Message History are sufficient). For admin testing you can temporarily select Administrator.
    • Copy the generated URL, open it in your browser, choose the server to add the bot to, and authorize it.

Example manual OAuth2 invite URL (replace CLIENT_ID and adjust permissions):

https://discord.com/oauth2/authorize?client_id=CLIENT_ID&permissions=8&scope=bot%20applications.commands

Bot usage

  • Start the bot with python bot.py.
  • In Discord, use !ping to check the bot is responsive.

Environment variables

  • DISCORD_TOKEN — The bot token from the Developer Portal. Keep this secret.

Contributing

  • Fork the repository and open a pull request with your changes.
  • Suggested tasks for contributors:
    • Add a cog demonstrating a useful feature (e.g., moderation, fun commands).
    • Add unit tests or integration tests for command parsing/helpers.
    • Add a CI workflow to run linting and tests on PRs.

Resources


If you want, I can also scaffold a cogs/ package, add a simple CI github/actions workflow, or add examples for slash commands. Which would you like next?

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages