Update button.py
added button search-by-emoji (emoji name and/or id)
@@ -24,7 +24,7 @@ class Buttoner(object):
return True
#get attributes of a button
- def findButton(self, label=None, customID=None, row=None, column=None, findFirst=False): #label, custom_id, row, column
+ def findButton(self, label=None, customID=None, row=None, column=None, emojiName=None, emojiID=None, findFirst=False):
buttons = []
#row
if row != None:
@@ -36,7 +36,16 @@ class Buttoner(object):
for index,c in enumerate(row["components"]):
#if button
if c["type"] == 2:
- if self._check([label, customID, column], [c.get("label"), c["custom_id"], index]):
+ if self._check(
+ [label, customID, column, emojiName, emojiID],
+ [
+ c.get("label"),
+ c["custom_id"],
+ index,
+ c.get("emoji", {}).get("name"),
+ c.get("emoji", {}).get("id"),
+ ],
+ ):
buttons.append(dict(c))
if findFirst:
return buttons
@@ -81,8 +90,8 @@ class Buttoner(object):
return dropdowns
#get constructed button data
- def getButton(self, label=None, customID=None, row=None, column=None):
- button = self.findButton(label, customID, row, column, findFirst=True)
+ def getButton(self, label=None, customID=None, row=None, column=None, emojiName=None, emojiID=None):
+ button = self.findButton(label, customID, row, column, emojiName, emojiID, findFirst=True)
if len(button)>0:
return {"component_type": 2, "custom_id": button[0]["custom_id"]}
else:
