A small example package
Project description
discord-python
A discord API wrapper made for developing discord bots in python.
Features
- Application Commands
- Message Components
- Modals
- Automatic Gateway Integration
- Low-level access to websockets
Installation
There is currently no package, so just grab the files and dump them in your directory.
Usage
# Create a client and add two commands.
client = Client.Client()
# Register a new application command /help with a string parameter called "test" and responds with the function "help"
client.registerApplicationCommand("help", Enums.ApplicationCommand.SUB_COMMAND, "my epic description", help, [ApplicationCommands.ApplicationCommandOption(3, "test", True)])
# Register another application command called /menu
client.registerApplicationCommand("menu", Enums.ApplicationCommand.SUB_COMMAND, "testing select menus", menu)
client.syncApplicationCommands()
client.run("BOT TOKEN HERE")
# For the /help command, the callback function is called help, but can be called anything.
# Instead of registering the commands as above, you can use a decorator as follows.
@client.AppCommand(name="help", type=Enums.ApplicationCommand.SUB_COMMAND, description="my epic description", parameters = [ApplicationCommands.ApplicationCommandOption(Enums.ApplicationCommand.STRING, "test", "description", True)])
def help(client : Client.Client, interaction : InteractionResponder.Interaction):
# Respond with a message saying, "Hello, World!"
response = InteractionResponder.InteractionResponseText(interaction=interaction, text="Hello, world!", ephemeral=True)
# Create an action row.
actionRow = InteractionResponder.ActionRow(client=client)
# Adds a button to the message with the option set by the user as the label
actionRow.addComponent(InteractionResponder.Button(interaction.options[0]['value'], Enums.ButtonStyle.BLURPLE, client, "test1", callback=callback_test1))
response.addActionRow(actionRow)
response.generateJSON()
# Send the message to discord!
message = Message.Message(url=response.url, method=Message.HTTPMethods.POST, json=response.json, client=client)
client.messageQueue.append(message)
Contributing
Feel free to open an issue to discuss any changes.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file discord_python_sniperthrilla-0.0.6.tar.gz.
File metadata
- Download URL: discord_python_sniperthrilla-0.0.6.tar.gz
- Upload date:
- Size: 25.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
110328e9698654e405f23d9ff9c1c12dfd4a152ce0d9def077c43035bf97236a
|
|
| MD5 |
ace17c2e95e59145dc5cadada39b225e
|
|
| BLAKE2b-256 |
35438d21cfc0a9e27f30befa388d3ffa6021a9ac3763857966a19c18e913c4de
|
File details
Details for the file discord_python_sniperthrilla-0.0.6-py3-none-any.whl.
File metadata
- Download URL: discord_python_sniperthrilla-0.0.6-py3-none-any.whl
- Upload date:
- Size: 28.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f17302d69f75f8644286766a4d1594b3fc88134ca8f9748848fa4855ceea643
|
|
| MD5 |
73ac95939888f7505482a40e534919a8
|
|
| BLAKE2b-256 |
2dfeac1b19e422de10d7bc8621589938bcb9028e8691f25c33427270e3dbe36a
|