Skip to main content

No project description provided

Project description

DisHook 🎣

DisHook is a small, lightweight Python package for creating and managing Discord webhook messages easily.

Features ✨

  • User-Friendly Integration: Simple API for creating and sending Discord webhook messages.
  • Rich Embed Support: Build visually appealing messages with titles, descriptions, fields, and colors.
  • Polling Functionality: Conduct polls with various options and durations.
  • Interactive Components: Add buttons and other interactive elements to webhook messages.
  • Efficient Design: Minimalistic approach ensures quick setup and optimal performance.

Installation 🚀

Install DisHook directly from the GitHub repository using pip:

pip install dishookr

Usage 🛠️

from dishookr import Webhook

webhook = Webhook("https://discord.webhook.url")
webhook.set_content("Hello, world!")

webhook.send()
Embed
from dishookr import Webhook, Embed, EmbedThumbnail

webhook = Webhook("https://discord.webhook.url")

webhook.set_content("This message has an attached embed!")

my_embed = Embed(
    title="Embed Title",
    description="This is an embedded message.",
    color=0x00ff00,
    thumbnail=EmbedThumbnail(url="https://cdn.discordapp.com/embed/avatars/0.png")
)

my_embed.add_field(name="Field 1", value="Value 1")

webhook.add_embed(my_embed)

webhook.send()

Polls
from dishookr import Webhook, Poll, PartialEmoji, PollMedia, PollAnswer

webhook = Webhook("https://discord.webhook.url")

webhook.set_content("A poll is attached!")

my_poll = Poll(
    question=PollMedia("What is your favorite color?"),
    duration=3,
    allow_multiselect=False,
)

my_poll.add_answer(PollMedia("Red", PartialEmoji(name="🟥")))
my_poll.add_answer(PollMedia("Green", PartialEmoji(name="🟩")))
my_poll.add_answer(PollMedia("Blue", PartialEmoji(name="🟦")))
my_poll.add_answer(PollMedia("Yellow", PartialEmoji(name="🟨")))
my_poll.add_answer(PollMedia("Other", PartialEmoji(name="❓")))
my_poll.add_answer(PollMedia("I don't know", PartialEmoji(name="🤷")))

webhook.add_poll(my_poll)

webhook.send()

Mentions
from dishookr import Webhook, AllowedMentions

webhook = Webhook("https://discord.webhook.url")

webhook.set_content("Lets test out the mentions system! <@1248973121864601694>")

webhook.set_allowed_mentions(
    AllowedMentions(
        users=[1248973121864601694], # Allows the mention to this specific user to take effect
        replied_user=False # Allows the mention to the replied user to take effect
    )
)

webhook.send()

Components
from dishookr import Webhook, ActionRow, Button

webhook = Webhook("https://discord.webhook.url")

webhook.set_content("This message has an attached action row! It even has a button!")

my_button = Button(
    label="Click me!",
    style=1,
    custom_id="button1"
)

my_action_row = ActionRow(
    components=[my_button]
)

webhook.add_component(my_action_row)

webhook.send()

Interaction Responses
from vortexkit import App, Request, JSONResponse
from dishookr import InteractionResponse, InteractionCallbackMessage, InteractionResponseType

app = App()

@app.route("/interaction-callback")
def interaction_callback(request: Request):
    if not request.method == "POST":
        return JSONResponse({"error": "Method not allowed"}, status_code=405)
    
    if not request.body["type"] == 3 and not request.body["data"]["custom_id"] == "button1":
        return JSONResponse({"error": "Invalid interaction type"}, status_code=400)
    
    my_dishook_response = InteractionResponse(
        type=InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
        data=InteractionCallbackMessage(
            content="You clicked the button!"
        )
    )

    return JSONResponse(
        my_dishook_response.__dict__()
    )


if __name == '__main__':
    app.run("0.0.0.0", 8080)

For more usage examples, check out the examples directory.

Contributing 🤝

Contributions are welcome! Please feel free to submit issues or pull requests. For major changes, please open an issue first to discuss what you would like to change.

License 📜

This project is licensed under the MIT License - see the LICENSE file for details.

About 👨‍💻

DisHook is a small, lightweight Discord webhook API wrapper created with Python by Daftscientist.

Python License

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

dishookr-0.1.1.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

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

dishookr-0.1.1-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file dishookr-0.1.1.tar.gz.

File metadata

  • Download URL: dishookr-0.1.1.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for dishookr-0.1.1.tar.gz
Algorithm Hash digest
SHA256 11a06b611a50c6d48bef404240a6b68c59497b636671defef2793f9f981781a0
MD5 546ccc73eb6c863e542e870c9e39edc1
BLAKE2b-256 852a7fbd57ba4e33c97275922b931bd5b5b320ccaa75a91f16ba04d4fc768310

See more details on using hashes here.

File details

Details for the file dishookr-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: dishookr-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for dishookr-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4ce3f956bc62beb62b2162258080d8c9fe0d7b90e94b3abcd764c98211ddae39
MD5 8d08059c6c12d9ad8ec5ecdf74409254
BLAKE2b-256 12665410bf5a06589a9c69685996eacb3851fa1f14b6cfa3dec3ab70383231f6

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