Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ms7m/dispike
An independent, simple to use, powerful framework for creating interaction-based Discord bots. Powered by FastAPI
https://github.com/ms7m/dispike
discord discord-slash-commands fastapi python
Last synced: about 2 months ago
JSON representation
An independent, simple to use, powerful framework for creating interaction-based Discord bots. Powered by FastAPI
- Host: GitHub
- URL: https://github.com/ms7m/dispike
- Owner: ms7m
- License: mit
- Created: 2020-12-23T05:29:40.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-09-07T08:00:19.000Z (over 2 years ago)
- Last Synced: 2024-09-15T04:42:09.641Z (3 months ago)
- Topics: discord, discord-slash-commands, fastapi, python
- Language: Python
- Homepage: https://dispike.ms7m.me/
- Size: 2.05 MB
- Stars: 37
- Watchers: 4
- Forks: 5
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- discord-api-libs - dispike - An independent, simple to use, powerful framework for creating interaction-based Discord bots. Powered by FastAPI (Libraries / Python)
README
dispike
âī¸ A simple to use, powerful framework for creating stateless, independent bots using Discord Slash Commands.
⥠Powered by FastAPI.
### Notice
****
As of 2022, I simply don't have the time to maintain this library. This library should function normally until Discord disables the v8 API. I hope I can resurrect this project in the future. If you would like to maintain or take over, I'm happy to help in the discord server, or sending me a quick email. :)
***## đĻ Installation
**Latest stable-version**
```
pip install dispike
```## đ Learn more
- Read documentation [here](https://dispike.ms7m.me)
- See an example bot [here](https://github.com/ms7m/dispike-example)
- Join our Discord Server [here](https://discord.gg/yGgRmEYjju)***
đ§âđģ Quick Start Examples
### Basic
```python
from dispike import Dispike, DiscordCommand, DiscordResponse
from dispike import IncomingDiscordSlashInteraction
from dispike.helper import Embedbot = 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
```python
import dispike
from dispike import interactions, DiscordCommand, DiscordResponse
from dispike import IncomingDiscordSlashInteraction
from dispike.helper import Embedclass 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** |
| Message Attachments | **â ī¸ Not Implemented** |## âšī¸ Notice
- Python 3.6+
- Does not speak over the discord gateway. [discord-py-slash-command is what you are looking for.](https://github.com/eunwoo1104/discord-py-slash-command).
- You will need a server to accept connections directly from discord!## đ§âđģ 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
- [Squidtoon99](https://github.com/Squidtoon99)
- [marshmallow](https://github.com/mrshmllow)