Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.


dispike

⚙️ A simple to use, powerful framework for creating stateless, independent bots using Discord Slash Commands.

⚡ Powered by FastAPI.


📦 Installation

Latest stable-version

pip install dispike

📚 Learn more

  • Read documentation here
  • See an example bot here
  • Join our Discord Server here

🧑‍💻 Quick Start Examples

Basic

from dispike import Dispike, DiscordCommand, DiscordResponse
from dispike import IncomingDiscordSlashInteraction
from dispike.helper import Embed

bot = Dispike(...)


command = DiscordCommand(
  name="stock", description="Get the latest active stocks in the market!"
)


@bot.on("stock")
async def handle_stock_request(stockticker: str, ctx: IncomingDiscordSlashInteraction) -> DiscordResponse:
  get_price = function(stockticker...)
  
  embed=Embed()
  embed.add_field(name="Stock Price for {stockticker}.", value="Current price is {get_price}", inline=True)
  embed.set_footer(text="Request received by {ctx.member.user.username}")
  return DiscordResponse(embed=embed)



if __name__ == "__main__":
    bot.register(command)
    bot.run()

Advanced

import dispike
from dispike import interactions, DiscordCommand, DiscordResponse
from dispike import IncomingDiscordSlashInteraction
from dispike.helper import Embed


class SampleGroupCollection(interactions.EventCollection):

    def __init__(self):
        self._api_key = "..."

    def command_schemas(self):
        return [
            DiscordCommand(
                name="lateststocks", description="Get the highest performing stocks in the market currently!"
            ),
            interactions.PerCommandRegistrationSettings(
                schema=DiscordCommand(
                    name="price",
                    description="return ticker price for server",
                    options=[],
                ),
                guild_id=11111111,
            )
        ]

    def get_stock_information(self, stock_ticker):
        return ...

    def get_portfolio_stats(self, user_id):
        return ...

    @interactions.on("lateststocks")
    async def latest_stocks(self, ctx: IncomingDiscordSlashInteraction) -> DiscordResponse:
        embed = Embed()

        # check user's porfolio by looking in the database by their discord ID
        portfolio_stats = self.get_portfolio_stats(
            ctx.member.user.id
        )

        embed.add_field(name="Stocks are doing good!", value=f"Current portfolio is {portfolio_stats}", inline=True)
        embed.set_footer(text="Request received by {ctx.member.user.username}")
        return DiscordResponse(embeds=[embed])

    @interactions.on("price")
    async def get_stock_price(self, ctx: IncomingDiscordSlashInteraction, ticker: str) -> DiscordResponse:
        embed = Embed()
        embed.add_field(name=f"Stock Price for 1.",
                        value=f"Current price is {self.get_stock_information(ticker)}", inline=True)
        embed.set_footer(text="Request received by {ctx.member.user.username}")
        return DiscordResponse(embeds=[embed])

## Inside seperate file

from dispike import Dispike, DiscordCommand

bot = Dispike(...)

bot.register_collection(SampleGroupCollection(), register_command_with_discord=True)

if __name__ == "__main__":
    bot.run(port=5000)

Discord API Coverage

View Coverage

API Endpoint Implementation
Get Global Application Commands ✅ Implemented
Create Global Application Command ✅ Implemented
Edit Global Application Command ✅ Implemented
Delete Global Application Command ✅ Implemented
Create Guild Application Command ✅ Implemented
Edit Guild Application Command ✅ Implemented
Delete Guild Application Command ✅ Implemented
Create Interaction Response ✅ Implemented
Edit Original Interaction Response ✅ Implemented
Delete Original Interaction Response ✅ Implemented
Create Followup Message ✅ Implemented
Edit Followup Message ✅ Implemented
Delete Followup Message ✅ Implemented
Data Models and Types ✅ Implemented
ApplicationCommand ✅ Implemented
ApplicationCommandOption ✅ Implemented
ApplicationCommandOptionType ✅ Implemented
ApplicationCommandOptionChoice ✅ Implemented
Interaction ✅ Implemented
Interaction Response ✅ Implemented
Message Components ✅ Implemented
Buttons (Message Components) ✅ Implemented
Action Rows (Message Components) ✅ Implemented
Message Select (Message Components) ✅ Implemented

ℹ️ Notice

🧑‍💻 Development

Help is wanted in mantaining this library. Please try to direct PRs to the dev branch, and use black formatting (if possible).

🎉 Special Thanks

Metadata

Release files for dispike 1.0.1b0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dispike 1.0.1b0
File Size Uploaded Provenance Actions
dispike-1.0.1b0.tar.gz 39.9 kB Without provenance Details for dispike-1.0.1b0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dispike 1.0.1b0
File Interpreter ABI Platform Actions
dispike-1.0.1b0-py3-none-any.whl Python 3 none any Details for dispike-1.0.1b0-py3-none-any.whl

Total release size: 90.3 kB

Release files / dispike-1.0.1b0.tar.gz

Download URL dispike-1.0.1b0.tar.gz
Size 39.9 kB
Tags Source
SHA-256 checksum
How to use checksums
76e35cd778d8a85fd21ec34f6a088dfe457a379126376ace7262d5a73942459b
BLAKE2b-256 checksum
How to use checksums
8d0259402415f6c5a72d41e50a3c462746592a34eb46762bb34b1a7e09abae49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.9.6 Darwin/20.5.0

Release files / dispike-1.0.1b0-py3-none-any.whl

Download URL dispike-1.0.1b0-py3-none-any.whl
Size 50.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9b2e4ab983580cb736cf64b281470163b51b86fb319b9055fbcb5ea75e3f4343
BLAKE2b-256 checksum
How to use checksums
ce36945ad69fd302530d44fa78e2309c9d171c5f6a77fe0b5dec79d5434878cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.9.6 Darwin/20.5.0

Security for dispike 1.0.1b0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page