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
Close
Hashes for discord_python_sniperthrilla-0.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a1eab300e92c81d4de05f9dafbd16df98b6592f0e21fca925b13866b4477cce |
|
MD5 | 05363b67ffbf0f56fc3a7278cb033d72 |
|
BLAKE2b-256 | f802f096c34b06e7197d6c7734ea22aa98e67d68717ab23b20eade9132a4e7dc |
Close
Hashes for discord_python_sniperthrilla-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a3c93ebdda42156cacdf9a321e268f3d028f9335041c276f72eb64a0f9cd41f |
|
MD5 | dd41cbb2c2a5b2a72f9e61ccee6920e6 |
|
BLAKE2b-256 | 634dd026564d23b5e4b40faffe784a7ed8629ef6c91d476544429a768c82bf89 |