mirror of
https://github.com/Paillat-dev/pycord-reactive-views.git
synced 2026-01-02 01:06:18 +00:00
🐛 Fix color_select.py example not changing embed color
This commit is contained in:
0
examples/__init__.py
Normal file
0
examples/__init__.py
Normal file
@@ -1,9 +1,9 @@
|
||||
# ruff: noqa: INP001
|
||||
import os
|
||||
|
||||
import discord
|
||||
from dotenv import load_dotenv
|
||||
from pycord_reactive_views import ReactiveSelect, ReactiveValue, ReactiveView
|
||||
from typing_extensions import override
|
||||
|
||||
load_dotenv()
|
||||
|
||||
@@ -71,6 +71,7 @@ class ColourSelector(ReactiveView):
|
||||
async def _colour_select_callback(self, interaction: discord.Interaction) -> None:
|
||||
await interaction.response.defer()
|
||||
self.colour = self.colour_select.values[0] # pyright: ignore[reportAttributeAccessIssue]
|
||||
self.shade = colors[self.colour][0]
|
||||
await self.update()
|
||||
|
||||
async def _shade_select_callback(self, interaction: discord.Interaction) -> None:
|
||||
@@ -79,6 +80,7 @@ class ColourSelector(ReactiveView):
|
||||
self.shade = discord.Colour(selected_shade)
|
||||
await self.update()
|
||||
|
||||
@override
|
||||
async def _get_embed(self) -> discord.Embed | None:
|
||||
return discord.Embed(
|
||||
title=f"{self.colour.capitalize()} {self.shade}",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# ruff: noqa: INP001
|
||||
import os
|
||||
|
||||
import discord
|
||||
@@ -26,7 +25,7 @@ class Counter(ReactiveView):
|
||||
self.reset_button = ReactiveButton(
|
||||
label="Reset",
|
||||
style=discord.ButtonStyle.danger,
|
||||
disabled=ReactiveValue(lambda: self.counter == 0, True),
|
||||
disabled=ReactiveValue(lambda: self.counter == 0, default=True),
|
||||
)
|
||||
self.counter_button.callback = self._increment
|
||||
self.reset_button.callback = self._reset
|
||||
|
||||
Reference in New Issue
Block a user