Skip to content

fix(discord-command-bot): fix setup.py script import and send json payload - #494

Closed
sundeep8967 wants to merge 1 commit into
appwrite:mainfrom
sundeep8967:fix/discord-command-bot-setup-491
Closed

sundeep8967 wants to merge 1 commit into
appwrite:mainfrom
sundeep8967:fix/discord-command-bot-setup-491

Conversation

@sundeep8967

Copy link
Copy Markdown

Summary

When Appwrite builds the Python variant of discord-command-bot via pip install -r requirements.txt && python src/setup.py:

  1. The relative import from .utils import throw_if_missing fails with ImportError: attempted relative import with no known parent package because Python runs the file directly as a top-level script.
  2. The registration request in setup.py sent data={...} while setting Content-Type: application/json. Discord expects a JSON string body, so this should be sent using json={...}.

Solution

  • Catch ImportError, ValueError on the relative import and fall back to top-level from utils import throw_if_missing when executed directly as a script.
  • Use json={...} in requests.post(...) so the command payload is properly serialized.

Fixes #491

…yload

When running setup.py as a script via build command `python src/setup.py`,
the relative import `from .utils import throw_if_missing` raised
ImportError (attempted relative import with no known parent package).
Fallback to absolute import `from utils import throw_if_missing` when
executed directly as a script.

Additionally, send the command registration payload using `json=`
instead of `data=` to ensure Discord's API receives a valid JSON body.

Fixes appwrite#491

Signed-off-by: sundeep8967 <sundeep8967@gmail.com>
@appwrite

appwrite Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The changed import and request serialization match the documented setup invocation and Discord’s JSON API expectations.

The Python Discord command setup script now falls back to importing its utility when run directly, and sends the command registration payload as JSON. This supports the documented build invocation and Discord’s expected request format.

Verdict New comments Fixed Still open
💬 Commented 0 0 0

Note

@sundeep8967 does not have write access to this repository, so Hansi does not approve automatically. A maintainer can review and approve.

📂 Walkthrough · 1
File Change
python/discord_command_bot/src/setup.py Added a direct-script import fallback and switched the registration request to a JSON payload.

Reviewed 8aaf32b · Details · Comment @appwrite review to re-run, or mention @appwrite with a question.

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@sundeep8967

Copy link
Copy Markdown
Author

Resolved upstream via #499 merged into main. Closing this PR.

@sundeep8967 sundeep8967 closed this Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Bug Report: discord-command-bot Python build fails in setup.py

1 participant