Skip to content

A versatile Discord bot built with Python, featuring moderation, utility, and fun tools.

License

Notifications You must be signed in to change notification settings

NEVARLeVrai/custom-discord-python-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

86 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Python Discord Bot

A complete Discord bot with numerous features, developed in Python using discord.py.


๐Ÿ“‹ Table of Contents


๐Ÿš€ Features

๐ŸŒ Internationalization (Full Support)

  • /setlang [language] โ€“ Change the bot's language (English en or French fr) for the current server.
  • Complete Coverage โ€“ All commands, system logs, and error responses are fully localized.
  • Server-Specific Support โ€“ Each server can have its own independent language setting.
  • Persisted Preference โ€“ Settings are saved in bot/lang/config.json and persist across restarts.

๐Ÿงฉ General Commands

  • /helps โ€“ Displays all available commands
  • /ping โ€“ Shows the bot's latency in ms
  • /version โ€“ Displays the bot's version
  • /report [message] โ€“ Report a bug or send feedback
  • /stop โ€“ Stops the bot (owner only)
  • /sync Re-sync slash commands (owner only)
  • /clearslash โ€“ Remove all slash commands (owner only)
  • /slashinfo โ€“ Display slash command diagnostics (owner only)

๐Ÿ›ก๏ธ Moderation

  • /clear [amount] โ€“ Delete messages (max 70)
  • /warn [@user] [reason] [count] โ€“ Warn a user
  • /resetwarn [@user] โ€“ Reset user warnings
  • /warnboard โ€“ Show warnings leaderboard
  • /kick [@user] [reason] โ€“ Kick a user
  • /ban [@user or ID] [reason] โ€“ Ban a user
  • /unban [ID] โ€“ Unban a user
  • /cleanraidsimple [name] โ€“ Delete a channel by name
  • /cleanraidmultiple [date] [time] โ€“ Delete channels by date
  • /giverole [@user] [@role] โ€“ Give a role (owner only)
  • /removerole [@user] [@role] โ€“ Remove a role (owner only)
  • /mp [@user or ID] [message] โ€“ Send a private message
  • /spam [count] [#channel or mention] [message] โ€“ Spam messages (admin only)
  • /banword [word] โ€“ Add a banned word
  • /unbanword [word] โ€“ Remove a banned word
  • /listbannedwords โ€“ Display all banned words

Per-Server System:

  • Warns, banned words, and language are server-specific โ€“ Each server has its own independent list of banned words, warns, and language preference.
  • No cross-server data โ€“ Settings from one server do not affect others.

Automatic Features:

  • Banned word detection โ€“ Automatically detects and deletes messages containing banned words (per server)
  • Automatic warn โ€“ Users receive a warn via DM when using a banned word (reason: "banned word used: [word]")
  • Automatic sanctions โ€“ 5 warns โ†’ 10 min timeout ยท 10 warns โ†’ 10 min timeout ยท 15 warns โ†’ kick ยท 20 warns โ†’ ban
  • Role protection โ€“ Protected roles are temporarily removed during sanctions and restored after timeout
  • Sanctions are server-specific โ€“ Warns are tracked separately for each server

๐Ÿงฐ Utility

  • /gpt [question] โ€“ Ask GPT a question
  • /dalle [prompt] โ€“ Generate an image using DALLยทE
  • /repeat [#channel or @user] [message] โ€“ Repeat a message
  • /8ball [question] โ€“ Ask the magic 8-ball
  • /hilaire โ€“ Hilaire game
  • /deldms โ€“ Delete all bot DMs (admin only)
  • /tts [language] [volume] [text] โ€“ Make the bot speak (e.g. /tts en 3.0 Hello)

The bot automatically joins the user's voice channel and stays connected for other audio features.


๐Ÿ”— Automatic Link Conversion

Automatically converts social-media links for cleaner Discord embeds:

  • Instagram โ†’ eeinstagram.com
  • Twitter/X โ†’ fxtwitter.com
  • Reddit โ†’ vxreddit.com (expands short links like redd.it)

Original messages are deleted and replaced with the optimized link.


๐ŸŽต Soundboard

  • /slist โ€“ List available sounds
  • /splay [number] โ€“ Play a sound (auto joins VC)
  • /leave โ€“ Leave VC
  • /sstop โ€“ Stop sound
  • /svolume [0-200] โ€“ Set soundboard volume
  • /srandom โ€“ Play random sounds every 1โ€“5 min
  • /srandomskip โ€“ Skip current random sound
  • /srandomstop โ€“ Stop random playback
  • /vkick [@user] โ€“ Kick a user from VC (admin only)

Supported formats : MP3 / MP4 / M4A / OGG / OPUS / WAV / FLAC / AAC


๐ŸŽต AudioPlayer (yt-dlp) - MAJOR UPDATE!

New Interactive UI with Buttons:

  • โฎ๏ธ Previous | โฏ๏ธ Play/Pause | โญ๏ธ Skip | ๐Ÿ” Loop
  • โช -15s | โฉ +15s | ๐Ÿ“‹ Queue | โน๏ธ Stop

Playback Commands:

  • /mplay [URL] โ€“ Play a video or audio from any supported site (YouTube, TikTok, X, etc.)
  • /msearch [query] โ€“ Search and play with interactive menu
  • /mskip โ€“ Skip the current track
  • /mstop โ€“ Stop playback and clear queue
  • /mpause โ€“ Pause the current track
  • /mresume โ€“ Resume playback
  • /leave โ€“ Disconnect from voice channel

Queue Management:

  • /mqueue โ€“ Display the queue
  • /mclearqueue โ€“ Clear the queue
  • /maddqueue [URL] โ€“ Add song to queue without playing
  • /mremovequeue [position] โ€“ Remove song from queue

Advanced Controls:

  • /mloop โ€“ Toggle loop mode

  • /mprevious โ€“ Play the previous track

  • /mseek [minutes] [seconds] โ€“ Seek to specific time

  • /mvolume [0-200] โ€“ Set music volume (real-time, no restart)

  • Dynamic Progress Bar โ€“ "Now Playing" embed includes a visual progress bar

  • Universal Local Playback (โฎ๏ธ) โ€“ The bot now automatically downloads all audio sources locally before playing. This ensures 100% stability, no buffering, and perfect seek/skip utility for every supported platform (YouTube, TikTok, SoundCloud, etc.).

  • Persistent UI โ€“ The player message is only replaced when a new track starts. It stays visible even if the song ends or the queue is empty.

  • Universal Seek Support โ€“ Skip buttons (+15s / -15s) now work perfectly for all platforms.

  • Session-Based Cleanup โ€“ Temporary audio files are preserved during your session for stability and cleared only when you leave or stop.

  • Universal Exit Listener โ€“ One-click cleanup even if the bot is kicked or timed out.

Supported platforms: see full list (YouTube, TikTok, X, Facebook, SoundCloud, Twitch, Vimeo, etc.)

Powered by yt-dlp.


๐Ÿงฌ Leveling System

  • /level [@user] โ€“ View level
  • /resetlevel โ€“ Reset all levels (admin only)
  • /levelsettings โ€“ Toggle leveling
  • /levelboard โ€“ Show leaderboard

Automatic Features:

  • Automatic XP โ€“ Each message = +1 XP (when leveling is enabled)
  • Level up formula โ€“ Level up when XP โ‰ฅ (level + 1)ยฒ
  • Level up notification โ€“ Automatic congratulation message when a user levels up

๐Ÿ“ฆ Installation

Requirements

Zero configuration required! The bot is portable.

  1. Prerequisites: Have Python 3.8+ installed.
  2. Launch the bot:
    • Double-click on run.bat (Windows).
    • Or run ./run.sh (Linux/Mac).

โœจ Magic: On first launch, the bot will automatically:

  • Install all Python dependencies (discord.py, yt-dlp, openai, etc.)
  • Download FFmpeg (for audio/soundboard)
  • Download Node.js (for AudioPlayer with yt-dlp)

All tools are installed in bot/bin/ and will not affect your system.

Python Dependencies

The bot automatically installs these packages from bot/core/requirements.txt

Token Configuration

Required: You need a Discord bot token to run the bot.

๐Ÿ“‹ How to get a Discord token:

  1. Go to Discord Developer Portal
  2. Create a new application or select an existing one
  3. Go to the Bot section
  4. Click Reset Token and copy your token
  5. Enable these Privileged Gateway Intents:
    • โœ… Presence Intent
    • โœ… Server Members Intent
    • โœ… Message Content Intent

๐Ÿ“ Configure the token:

Current configuration: The bot reads the token from a file path specified in bot/core/main.py (line 31).

Default path:

'token_file': "C:/Users/Danie/Mon Drive/Autres/Bot Python Discord/token.txt"

To configure:

  1. Edit bot/core/main.py line 31 with your desired path, OR
  2. Create a token.txt file at the path specified in main.py
  3. Put your Discord token inside (just the token, nothing else)

Example token.txt:

MTIzNDU2Nzg5MDEyMzQ1Njc4.GhIjKl.MnOpQrStUvWxYz1234567890AbCdEfGhIjKlMnOp

โš ๏ธ Important: Never share your token or commit it to Git (already in .gitignore)

๐Ÿ”ง Alternative: Use a local .env file (Optional)

For better portability, you can use a .env file in the project root:

.env file:

DISCORD_TOKEN=your_token_here
GPT_TOKEN=your_gpt_token_here

Note: To use .env, you need to modify bot/core/main.py to load from environment variables instead of files.


๐Ÿš€ How to Launch

The project includes convenient scripts in the root directory that automatically check for dependencies (Python, Node.js, FFmpeg).

๐ŸชŸ Windows

Double-click on run.bat in the root folder, or run in terminal:

run.bat

๐Ÿง Linux / Mac

Make the script executable and run it:

chmod +x run.sh
./run.sh

๐Ÿ› ๏ธ Administration Tools

Reset Bot

A comprehensive tool is available to reset the bot's data (warns, levels, logs, banned words) and clear cache to zero if needed.

Run:

python bot/tools/reset_bot.py

Note: This will perform a total cleanup of dynamic data and logs, but will preserve core configurations like update_logs.json.


โš™๏ธ Project Structure

Python-Discord-Bot/
โ”œโ”€โ”€ run.bat                    # Launcher (Windows)
โ”œโ”€โ”€ run.sh                     # Launcher (Linux/Mac)
โ””โ”€โ”€ bot/
    โ”œโ”€โ”€ bin/                   # Portable tools (FFmpeg, Node.js) - Created automatically
    โ”œโ”€โ”€ core/                  # Source Code
    โ”‚   โ”œโ”€โ”€ main.py            # Entry point
    โ”‚   โ”œโ”€โ”€ run.py             # Launcher logic & auto-installation
    โ”‚   โ”œโ”€โ”€ requirements.txt
    โ”‚   โ”œโ”€โ”€ services/          # Business logic (Audio, Leveling, Mod...)
    โ”‚   โ”œโ”€โ”€ slash_commands/    # Slash commands (/)
    โ”‚   โ””โ”€โ”€ auto_commands/     # Auto commands & Error handling
    โ”œโ”€โ”€ json/                  # Data (config, warns, levels...)
    โ”œโ”€โ”€ lang/                  # Localization (fr.json, en.json)
    โ”œโ”€โ”€ img/                   # Images / Assets
    โ”œโ”€โ”€ Sounds/                # Audio files for Soundboard
    โ”œโ”€โ”€ logs/                  # Log files
    โ””โ”€โ”€ tools/                 # Admin scripts (reset_bot.py, clean_lang.py)

๐Ÿงฉ Slash Commands

All commands are available as slash commands and sync automatically on startup. Use :

  • /sync โ†’ Force sync
  • /clearslash โ†’ Remove all slash commands
  • /slashinfo โ†’ Diagnostics

Global sync may take up to 1 hour to propagate.


๐Ÿ›ก๏ธ Error Handling

Comprehensive error system with centralized error handling:

  • Unknown command
  • Missing permissions
  • Invalid arguments
  • Cooldown active
  • Owner-only command
  • Not usable in DM
  • HTTP errors
  • Resource not found
  • Attribute errors

All errors are also logged to the console with full tracebacks.


โš ๏ธ Warnings

  • Keep all tokens private
  • Ensure required permissions are granted (including Intent Message Content)
  • Some commands are restricted to admins or owners

๐Ÿ› Bug Reporting

Use :

/report [message]

to send feedback or report a bug. A ticket is automatically sent to the developer via webhook.


Developed with โค๏ธ in Python by NEVAR

About

A versatile Discord bot built with Python, featuring moderation, utility, and fun tools.

Topics

Resources

License

Stars

Watchers

Forks

Languages