Skip to content

NEVARLeVrai/custom-discord-python-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

96 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
  • /say [#channel] [message] โ€“ Send a message in a channel
  • /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)

๐Ÿ“‹ Channel Copy & Forward

Copy entire channel histories or forward specific messages โ€” same server or cross-server.

  • /copychannel [source] [destination] [after_message] โ€“ Copy all messages from a channel to another (admin only)
  • /forwardmsg [message_id] [channel] [source_channel] โ€“ Forward a specific message (admin only)

Features:

  • Full-Fidelity Webhooks โ€“ Exclusively uses Webhooks to perfectly clone the original author's name and avatar without ugly "Forwarded" tags
  • True Cross-Server Support โ€“ Provide a raw channel ID for both source and destination to seamlessly clone channels between different servers
  • Resume Capability โ€“ If interrupted, use the after_message parameter with the last copied message ID to resume
  • Smart Rate Limiting โ€“ Built-in anti-spam delays to prevent API deadlocks and Discord 429 bans
  • Real-Time Progress โ€“ Live progress embed with ETA that auto-cleans system messages
  • Attachment Safety โ€“ Automatically skips files exceeding Discord's 25 MB upload limit

๐Ÿ•’ Reminders & Timezone

Personal reminder system with timezone awareness.

  • Commands: /reminder set, /reminder list, /reminder cancel, /reminder timezone set.
  • Time Formats:
    • Relative: 10m, 1h, 2d
    • Absolute (Time): 18:30, 18:30:45
    • Absolute (Date): 27/02 18:30, 27/02/26 18:30, 27/02/2026 18:30
  • Confirmation: Uses Discord dynamic timestamps (auto-adjusts to your device).
  • Spam Mode: Optional recurring alerts until acknowledged via a button.

๐Ÿงน Maintenance & Reset

  • Cleanup Tool: bot/tools/reset_bot.py is now fully localized (FR/EN) and ensures data integrity.
  • Launcher UX: run.py displays real-time download speed and progress for dependencies.

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


๐ŸŽต 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.


๐Ÿ”— Link Conversion (VxT-Python Port)

Full-fidelity port of VxT-Python (conversion of social media links for better embeds).

  • Zero configuration needed โ€“ Automatically converts links from X (Twitter), Instagram, TikTok, and more.
  • Unbundled Commands โ€“ All 14 configuration modules are available as top-level vxt- commands.
  • /vxt-toggle [type] โ€“ Toggle conversion for all, text, images, videos, or polls.
  • /vxt-direct-media toggle [type] โ€“ Toggle subdomain addition for Twitter images/videos.
  • /vxt-direct-media channel [action] [channel] โ€“ Manage allowed/prohibited channels.
  • /vxt-direct-media multiple-images [option] โ€“ Configure mosaic or conversion for multi-images.
  • /vxt-direct-media quote-tweet [option] โ€“ Configure quote tweet behavior in direct media.
  • /vxt-translate toggle โ€“ Enable/disable tweet translation.
  • /vxt-translate language [language] โ€“ Set target language with autocomplete.
  • /vxt-blacklist [action] [user/role] โ€“ Manage blacklisted users and roles.
  • /vxt-mention remove [action] [mention] โ€“ Manage mentions to ignore.
  • /vxt-mention remove-all [groups] โ€“ Toggle removal for all, roles, or users mentions.
  • /vxt-conversion-list add/update/remove/list โ€“ Manage custom domain conversions.
  • /vxt-quote-tweet link-conversion [type] โ€“ Toggle specific quote tweet link conversion details.
  • /vxt-quote-tweet remove-quoted-tweet โ€“ Toggle removal of original quoted tweets.
  • /vxt-message [delete_original] [other_webhooks] โ€“ Configure webhook and deletion behavior.
  • /vxt-retweet [delete_original] โ€“ Toggle original deletion for retweets.
  • /vxt-webhooks [preference] [reply] โ€“ Set preference between webhooks and replies.
  • /vxt-delete-bot-message [toggle] [count] โ€“ Configure bot message deletion via reactions.
  • /vxt-name-preference [preference] โ€“ Choose between display name and username for webhooks.
  • /vxt-reset-settings โ€“ Reset all VxT settings to default for the server.
  • /vxt-error-list โ€“ List recent conversion errors.

Uses webhooks to seamlessly replace messages while maintaining user identity.


๐Ÿงฌ 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) with real-time speed & progress tracking
  • Download Node.js (for AudioPlayer) with real-time speed & progress tracking

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


๐Ÿ“œ Credits & Acknowledgements

  • VxT-Python: Special thanks to Aris-In-Vain for the original Link Conversion logic and configuration structure.
  • Link Services: Powered by FixTweet (dangeredwolf), InstaFix (Wikidepia), and others.
  • Tools: Powered by discord.py and yt-dlp.

About

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

Topics

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Contributors

Languages