mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-04 00:55:19 +00:00
Add item parameter to DynamicItem.from_custom_id
This commit is contained in:
@ -45,10 +45,10 @@ class DynamicCounter(
|
||||
|
||||
# This method actually extracts the information from the custom ID and creates the item.
|
||||
@classmethod
|
||||
async def from_custom_id(cls, interaction: discord.Interaction, match: re.Match[str], /):
|
||||
async def from_custom_id(cls, interaction: discord.Interaction, item: discord.ui.Button, match: re.Match[str], /):
|
||||
count = int(match['count'])
|
||||
user_id = int(match['id'])
|
||||
return cls(count, user_id)
|
||||
return cls(user_id, count=count)
|
||||
|
||||
# We want to ensure that our button is only called by the user who created it.
|
||||
async def interaction_check(self, interaction: discord.Interaction) -> bool:
|
||||
|
@ -51,7 +51,7 @@ class DynamicButton(discord.ui.DynamicItem[discord.ui.Button], template=r'button
|
||||
|
||||
# This is called when the button is clicked and the custom_id matches the template.
|
||||
@classmethod
|
||||
async def from_custom_id(cls, interaction: discord.Interaction, match: re.Match[str], /):
|
||||
async def from_custom_id(cls, interaction: discord.Interaction, item: discord.ui.Button, match: re.Match[str], /):
|
||||
user_id = int(match['id'])
|
||||
return cls(user_id)
|
||||
|
||||
|
Reference in New Issue
Block a user