Skip to content

Simple statically typed (relatively) Discord API Wrapper

License

Notifications You must be signed in to change notification settings

Mmesek/mdiscord

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mDiscord

Open in Visual Studio Code

GitHub

CodeFactor Grade Lines of code GitHub code size in bytes GitHub repo size

Discord

Simple (relatively) typehinted Discord API Wrapper with type casting.

Made (and meant) to work in conjunction with MFramework.py hence it's usage on it's own is rather limited (Read: It's mainly a REST wrapper with Gateway's Dispatch)

Features

  • Generated 1:1 Mapping of models & endpoints based on Discord documentation. All endpoints are available as methods of Client.
  • In theory 100% of API coverage.
  • Iterating prioritizable event listeners supporting predicates without blocking them.
  • Differentiating direct messages from guild messages by prependeding them with DIRECT_.
  • Automatic skipping of events sent by bots (Those containing is_bot attribute set to True)
  • Embed builder respecting message limits without throwing.
  • Convenience methods for models in types.py.
  • Just a simple API wrapper with Gateway client without anything fancy, really.

Examples

Basic (Websocket) usage example:

cfg = {
    "DiscordTokens": {
        "Bot": "TOKEN"
    }
}

from mdiscord import onDispatch, Message, Client

@onDispatch
async def message_create(ctx: Client, msg: Message):
    pass

async def main():
    client = Client("Bot", cfg, None, None)
    while True:
        async with client:
            await client.receive()

import asyncio
asyncio.run(main())

HTTP only (REST) usage example:

from mdiscord.http_client import HTTP_Client
import asyncio

webhook_id = 0
webhook_token = ""

async def main():
    e = HTTP_Client()
    await e.execute_webhook(webhook_id, webhook_token, content="Hello")

asyncio.run(main())

Contributing

While PR's are welcome, for command-related capability contributions, visit MFramework.py repo.

About

Simple statically typed (relatively) Discord API Wrapper

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages