Discord bot permission scanner - Analyzes discord.py code to detect required permissions and generate invite links
Project description
mper
Discord Bot Permission Scanner - discord.pyのコードを解析し、必要なパーミッションを検出して招待リンクを生成するツール。
特徴
| 機能 | 説明 |
|---|---|
| メソッドベース検出 | .ban(), .kick(), .send() などのメソッド呼び出しからBotパーミッションを自動推測 |
| 証拠トラッキング | どのファイルの何行目でどのパーミッションが必要かを表示 |
| 全49パーミッション対応 | Discord APIの全パーミッションをサポート |
| コンテキスト認識 | member.edit(nick=...) と member.edit(mute=...) を区別 |
| デコレータサポート | @bot_has_permissions(補助)、@has_permissions(ユーザー要件のみ) |
| アップデート通知 | 新しいバージョンがリリースされた際にCLIで通知 |
インストール
pip install mper
使い方
CLI
# 基本的な使い方
mper /path/to/bot/directory CLIENT_ID
# 詳細レポート付き
mper /path/to/bot/directory CLIENT_ID --report
# 詳細出力
mper /path/to/bot/directory CLIENT_ID --verbose
# ディレクトリを除外
mper /path/to/bot/directory CLIENT_ID --exclude tests docs
# カスタムOAuth2スコープ
mper /path/to/bot/directory CLIENT_ID --scope bot --scope applications.commands
# プレーンテキスト出力(色なし)
mper /path/to/bot/directory CLIENT_ID --plain
CLIオプション
| オプション | 説明 |
|---|---|
--report |
証拠付きの詳細パーミッションレポートを表示 |
--verbose, -v |
スキャン中の詳細出力を表示 |
--no-inferred |
デコレータからの宣言パーミッションのみ使用 |
--exclude |
除外するディレクトリを追加 |
--scope |
招待リンクのOAuth2スコープ(デフォルト: bot, applications.commands) |
--output, -o |
招待リンクの出力ファイル(デフォルト: bot_invite_url.txt) |
--no-color |
色付き出力を無効化 |
--plain |
プレーンテキスト出力(スタイルなし) |
ライブラリとして使用
import mper
# 簡単に招待URLを生成(CLIと同じ動作)
url = mper.generate_invite_url("./my_bot", client_id="123456789012345678")
print(url)
# 詳細なスキャン結果を取得
result = mper.scan_directory("./my_bot")
print(f"検出されたパーミッション: {result['invite_link_permissions']}")
# パーミッション名から整数値を計算
perm_int = mper.calculate_permission_integer({'send_messages', 'ban_members'})
# カスタム招待URLを作成
url = mper.create_invite_link(
client_id="123456789012345678",
permissions=perm_int,
scopes=['bot', 'applications.commands']
)
詳細な使用例は examples/ を参照してください。
出力例
╭──────────────────────────────────────────────────╮
│ mper - Discord Bot Permission Scanner │
╰──────────────────────────────────────────────────╯
Scanning: /path/to/bot
Scanned 5 files (0 with errors)
┌─────────────────────────────────────────────────┐
│ Detected Permissions (from method calls) │
├─────────────────┬───────────┬───────────────────┤
│ Permission │ Bit Value │ Evidence │
├─────────────────┼───────────┼───────────────────┤
│ ban_members │ 0x4 │ bot.py:15 │
│ manage_messages │ 0x2000 │ bot.py:25 │
│ send_messages │ 0x800 │ bot.py:10, 20, 30 │
└─────────────────┴───────────┴───────────────────┘
╔══════════════════════════════════════════════════╗
║ 🔗 INVITE LINK ║
╠══════════════════════════════════════════════════╣
║ https://discord.com/oauth2/authorize?... ║
╚══════════════════════════════════════════════════╝
仕組み
┌─────────────────────────────────────────────────────────────┐
│ mper スキャンプロセス │
├─────────────────────────────────────────────────────────────┤
│ │
│ 1. メソッドベース検出 (PRIMARY) │
│ Python AST解析 → discord.pyメソッド検出 → パーミッション推測 │
│ 例: member.ban() → ban_members │
│ │
│ 2. @bot_has_permissions (SUPPLEMENTARY) │
│ 明示的なBot権限宣言 → 招待リンクに追加 │
│ │
│ 3. @has_permissions (REFERENCE ONLY) │
│ ユーザー権限要件 → レポートに表示のみ(招待リンクには不含) │
│ │
└─────────────────────────────────────────────────────────────┘
対応パーミッション
Discord APIの全49パーミッション(ビット0-46, 49-50)に対応しています。
詳細は Discord API Documentation を参照してください。
ライセンス
MIT License - 詳細は LICENSE を参照してください。
Issues
問題や要望がある場合は、適切なタグを付けてIssueを作成してください:
| タグ | 用途 |
|---|---|
bug |
バグ報告 |
enhancement |
機能要望 |
question |
質問 |
クレジット
- 開発者: @FreeWiFi7749
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mper-1.1.1.tar.gz.
File metadata
- Download URL: mper-1.1.1.tar.gz
- Upload date:
- Size: 29.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea4b8758cd0f4d74bb805dd6d5b9a9000944b3fcba6b108a041380026fcaa4bf
|
|
| MD5 |
76bd7f86a76cfec003d6d7457d904d3e
|
|
| BLAKE2b-256 |
7fcba8277e553a57cb18631d3893499107163063372e89817b87539720407071
|
Provenance
The following attestation bundles were made for mper-1.1.1.tar.gz:
Publisher:
publish.yml on easy-make-invite-url-for-discord-bot/mper.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mper-1.1.1.tar.gz -
Subject digest:
ea4b8758cd0f4d74bb805dd6d5b9a9000944b3fcba6b108a041380026fcaa4bf - Sigstore transparency entry: 776236862
- Sigstore integration time:
-
Permalink:
easy-make-invite-url-for-discord-bot/mper.py@ccfbaaad215a66e659835837095ae49005966ebc -
Branch / Tag:
refs/heads/main - Owner: https://github.com/easy-make-invite-url-for-discord-bot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ccfbaaad215a66e659835837095ae49005966ebc -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file mper-1.1.1-py3-none-any.whl.
File metadata
- Download URL: mper-1.1.1-py3-none-any.whl
- Upload date:
- Size: 23.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bac6ac15538d84ba42ad0e0adc32d7cfaabba6460d49fbbeddfeb41c8d2893a4
|
|
| MD5 |
c32054806f19409a25602324a7cf696d
|
|
| BLAKE2b-256 |
357f71f6f9c38e1db8454f4afad000409046b162a3056ac692c0607ac4790b07
|
Provenance
The following attestation bundles were made for mper-1.1.1-py3-none-any.whl:
Publisher:
publish.yml on easy-make-invite-url-for-discord-bot/mper.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mper-1.1.1-py3-none-any.whl -
Subject digest:
bac6ac15538d84ba42ad0e0adc32d7cfaabba6460d49fbbeddfeb41c8d2893a4 - Sigstore transparency entry: 776236863
- Sigstore integration time:
-
Permalink:
easy-make-invite-url-for-discord-bot/mper.py@ccfbaaad215a66e659835837095ae49005966ebc -
Branch / Tag:
refs/heads/main - Owner: https://github.com/easy-make-invite-url-for-discord-bot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ccfbaaad215a66e659835837095ae49005966ebc -
Trigger Event:
workflow_dispatch
-
Statement type: