Skip to main content

Discord bot permission scanner - Analyzes discord.py code to detect required permissions and generate invite links

Project description

mper.py

Discord bot permission scanner - Analyzes discord.py code to detect required permissions and generate invite links.

discord.pyボットのコードを解析し、必要な権限を検出して招待リンクを生成するツールです。

Features / 機能

  • Method-based detection (PRIMARY): Detects discord.py method calls (.ban(), .kick(), .send(), etc.) and infers required BOT permissions
  • Evidence tracking: Shows which method calls at which lines require which permissions
  • All 49 Discord permissions: Supports all Discord API permissions (as of 2025-12-22)
  • Context-aware detection: Handles member.edit(nick=...), member.edit(mute=...), etc.
  • Decorator support: @bot_has_permissions (supplementary), @has_permissions (user requirements only)

Installation / インストール方法

pip install mper

Usage / 使い方

mper /path/to/bot/directory CLIENT_ID

Examples / 例

# Basic usage
mper /home/user/my_discord_bot 123456789012345678

# With detailed report
mper /home/user/my_discord_bot 123456789012345678 --report

# Verbose output
mper /home/user/my_discord_bot 123456789012345678 --verbose

# Exclude directories
mper /home/user/my_discord_bot 123456789012345678 --exclude tests docs

# Custom OAuth2 scopes
mper /home/user/my_discord_bot 123456789012345678 --scope bot --scope applications.commands

CLI Options / オプション

Option Description
--report Print detailed permissions report with evidence
--verbose, -v Show detailed output during scanning
--no-inferred Only use declared permissions (from decorators)
--exclude Additional directories to exclude
--scope OAuth2 scopes for invite link (default: bot, applications.commands)
--output, -o Output file for invite link (default: bot_invite_url.txt)

Output Example / 出力例

======================================================================
DETECTED PERMISSIONS (from method calls - PRIMARY)
----------------------------------------------------------------------

ban_members (0x4):
  bot.py:15 -> member.ban()
    [high] Ban a member from the guild

manage_messages (0x2000):
  bot.py:25 -> channel.purge()
    [high] Bulk delete messages

======================================================================
INVITE LINK PERMISSIONS
======================================================================
Source: method-based detection + @bot_has_permissions

  Permissions: ban_members, manage_messages, send_messages
  Integer: 10246
  Hex: 0x2806

How It Works / 仕組み

  1. Method-based detection (PRIMARY): Scans Python AST for discord.py method calls and maps them to required permissions
  2. @bot_has_permissions (SUPPLEMENTARY): Explicit bot permission declarations are added to invite link
  3. @has_permissions (REFERENCE ONLY): User permission requirements are shown in report but NOT included in invite link

Supported Permissions / 対応権限

All 49 Discord permissions are supported (bits 0-46, 49-50). See Discord API Documentation for details.

License / ライセンス

This project is licensed under the MIT License. See LICENSE for details.

このツールはMITライセンスのもとで公開されています。複製、編集、再公開は基本的に全て許可されています。

Issues / 質問や不具合の報告

Please create issues with appropriate tags:

  • bug - Bug reports / バグ報告
  • enhancement - Feature requests / 要望
  • question - Questions / 質問

Credits / クレジット

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mper-1.0.0.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mper-1.0.0-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file mper-1.0.0.tar.gz.

File metadata

  • Download URL: mper-1.0.0.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for mper-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6044c770d055a51e8be3aec8edf41d02fc032e3ae196ae3e4cfa6fe40c55ad01
MD5 74fbf797aab6d011243062502714ab73
BLAKE2b-256 c2be4722de1a85270852854c2b094f6285e0f26fa0e73819c8ab32dd0b8674f0

See more details on using hashes here.

File details

Details for the file mper-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mper-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for mper-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4558427d8a099815e2ac196cd52f7fbdd1a2c19dcf9193214d129c2e12075212
MD5 56c655f4ffb1c15f06494ba4b5ec7036
BLAKE2b-256 10e276f628ac610e593ab5e3be5e431b5dbd30c898dbe8cec13f31e9ea273787

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page