Provide discord buttons feature for discord.py

Overview

dpy_buttons

wrapper library for discord.py, providing discord buttons feature.

Future of the library

Will be merged into discord interaction api library, discord_interactions

  1. Future structure :
discord_interactions
ㄴslash_commands
  ㄴ ...
ㄴcomponents
  ㄴbuttons // This project
    ㄴ ..
  ㄴ ..     // Prepare for future components
  1. Future implementation
# Before
class Button: ...

# After
class Component: ... # Parent class for all components
class Button(Component): ...

Example

from discord_buttons import Button, ButtonStyle, ButtonContext, ButtonMessage, ButtonClient, ButtonCache

# Create button
btn_red = Button(label='Red Button!', style=ButtonStyle.Red, custom_id='red_btn')
btn_url = Button(label='URL Button!', style=ButtonStyle.URL, url='https://...')

# Register button click handler
@btn_red.listen  # Thinking about name 'on_click'
async def handler(ctx: ButtonContext):
    # send message on channel
    # sent messages are wrapped as a objet 'ButtonMessage', which extends discord.py's Message and contains Button objects
    msg: ButtonMessage = await ctx.send(...)
    # send reply on button's message
    await ctx.reply(...)
    # Access to clicked button
    print(ctx.button)


# Client object which extends discord.py's Client to handle button event on socket response event.
# ButtonBot, AutoshardedButtonClient, AutoShardedButtonBot are also available.
client = ButtonClient()

@client.event
async def on_message(msg):
    if msg.content == '!buttons':
        await msg.channel.send(
            # Buttons can be wrapped in 2-dimensional array
            # Internally, this is implemented using component with type 1.
            buttons=[
                [Button('Blurple Button!, ButtonStyle.Blurple, 'blurple_btn'), Button('Gray Button!', ButtonStyle.Gray, 'gray_btn')]
                # You can get Button instance which is created in other code using ButtonCache().get_button(custom_id)  *URL Buttons are not cached, so they can't be retrieved.
                # ButtonCache implements Singleton pattern, so whenever you create instance, you can get same object.
                [ButtonCache().get_button('red_btn'), Button('Green Button!', ButtonStyle.Green, 'green_btn')]
                [btn_url]
            ]
        )
Owner
Minjun Kim (Lapis0875)
Korean student who loves making things by himself. Learning programming. / 직접 무언가를 만드는 일을 좋아하는 한국 학생이에요. 프로그래밍을 공부하고 있어요!
Minjun Kim (Lapis0875)
gnosis safe tx builder

Ape Safe: Gnosis Safe tx builder Ape Safe allows you to iteratively build complex multi-step Gnosis Safe transactions and safely preview their side ef

228 Dec 22, 2022
Source code for Profile REST API

PROJECT PROFILE REST API Creating local development server: We will create a local development server that can run and test our API as we build it. We

1 Mar 29, 2022
Aws-lambda-requests-wrapper - Request/Response wrapper for AWS Lambda with API Gateway

AWS Lambda Requests Wrapper Request/Response wrapper for AWS Lambda with API Gat

1 May 20, 2022
Discord RPC for Notion written in Python

Discord RPC for Notion This is a program that allows you to add your Notion workspace activities to your Discord profile. This project is currently un

Thuliumitation 1 Feb 10, 2022
A python script to download twitter space, only works on running spaces (for now).

A python script to download twitter space, only works on running spaces (for now).

279 Jan 02, 2023
KTUN Öğrenci Bilgi Sistemine bağlanıp her 15 dakikada notları kontrol eden ve değişiklik olduğu zaman size Discord Webhook ile mesaj atan uygulama.

KTUN_Obis KTUN Öğrenci Bilgi Sistemi KTUN Öğrenci Bilgi Sistemine selenium kullanarak girip setttings.py dosyasında verdiğiniz bilgeri doldurup ardınd

İbrahim Uysal 5 Oct 27, 2022
Docker image for epicseven gvg qq chatbot based on Xunbot

XUN_Langskip XUN 是一个基于 NoneBot 和 酷Q 的功能型QQ机器人,目前提供了音乐点播、音乐推荐、天气查询、RSSHub订阅、使用帮助、识图、识番、搜番、上车、磁力搜索、地震速报、计算、日语词典、翻译、自我检查,权限等级功能,由于是为了完成自己在群里的承诺,一时兴起才做的,所

Xavier Xiong 2 Jun 08, 2022
A discord bot written in discord.py to manage custom roles assigned to boosters of your server.

BBotty A discord bot written in discord.py to manage custom roles assigned to boosters of your server. v0.0.1-alpha released! This version is incomple

Oui002 1 Nov 27, 2021
Palo Alto Networks PAN-OS SDK for Python

Palo Alto Networks PAN-OS SDK for Python The PAN-OS SDK for Python (pan-os-python) is a package to help interact with Palo Alto Networks devices (incl

Palo Alto Networks 281 Dec 09, 2022
Prisma Cloud utility scripts, and a Python SDK for Prisma Cloud APIs.

pcs-toolbox Prisma Cloud utility scripts, and a Python SDK for Prisma Cloud APIs. Table of Contents Support Setup Configuration Script Usage CSPM Scri

Palo Alto Networks 34 Dec 15, 2022
A powerful, cool and well-made userbot for your Telegram profile with promising extension capabilities.

Telecharm userbot A powerful, fast and simple Telegram userbot written in Python 3 and based on Pyrogram 1.X. Currently in active WIP state, so feel f

Daniil Kovalenko 16 Dec 01, 2022
This is a DCA crypto trading bot built for Binance written in Python

This is a DCA crypto trading bot built for Binance written in Python. It works by allowing you to DCA at an interval of your choosing and reports back on your average buy price as well as a chart con

Andrei 55 Oct 17, 2022
A Simple Telegram Maths Calculator Bot

Calculator-Bot-v1 A Simple Telegram Maths Calculator Bot Demo BOT LINK: Variables Variables Required Variables API_HASH: Get

ᗪᗩᖇK ✞Oᖇᗪ 1 Dec 18, 2021
A modern,feature-rich, and async ready API wrapper for Discord written in Python

discord.io A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. Key Features Modern Pythonic API using asyn

Vincent 18 Jan 02, 2023
Unarchive Bot for Telegram

Telegram UnArchiver Bot UnArchiveBot: 🇬🇧 Bot that allows you to extract supported archive formats in telegram. 🇹🇷 Desteklenen arşiv biçimleri tele

Hüzünlü Artemis [HuzunluArtemis] 25 May 07, 2022
A continued fork of Disco

Orca Orca is an extensive and extendable Python 3.x library for the Discord API. orca boasts the following major features: Expressive, functional inte

RPS 4 Apr 03, 2022
This is a Discord script that will provide a QR Code to your scholars for Axie Infinity.

DiscordQRCodeBot This is a Discord script that will provide a QR Code to your Axie Infinity scholars. Setup Run Ubuntu on AWS ec2 instance Dowloads al

ZracheSs | xyZ 24 Oct 05, 2022
A user reconnaisance tool that extracts a target's information from Instagram, DockerHub & Github.

A user reconnaisance tool that extracts a target's information from Instagram, DockerHub & Github. Also searches for matching usernames on Github.

Richard Mwewa 127 Dec 22, 2022
→ Comando Básico para Python Discord

Discord.py · Código @client.event async def on_ready(): print('He iniciado sessión en: {0.user}'.format(client)) @client.event async def on_messa

Panda.xyz 4 Mar 12, 2022
Sadew Jayasekara 23 Oct 21, 2022