mirror of
https://github.com/Paillat-dev/pycord-reactive-views.git
synced 2026-01-02 01:06:18 +00:00
First commit
This commit is contained in:
19
examples/test.py
Normal file
19
examples/test.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import discord
|
||||
from pycord_reactive_views import ReactiveButton, ReactiveView
|
||||
|
||||
bot = discord.Bot()
|
||||
|
||||
|
||||
class Counter(ReactiveView):
|
||||
"""A simple counter view that increments a counter when a button is clicked."""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.counter = 0
|
||||
self.counter_button = ReactiveButton(value=lambda: self.counter)
|
||||
self.counter_button.callback = self._button_callback
|
||||
self.add_item(self.counter_button)
|
||||
|
||||
async def _button_callback(self, interaction: discord.Interaction):
|
||||
await interaction.response.defer()
|
||||
self.counter += 1
|
||||
Reference in New Issue
Block a user