Skip to content

Commit

Permalink
Add SelectOption.__str__
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapptz committed Jul 5, 2021
1 parent 7598865 commit feb0f7f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions discord/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ def __repr__(self) -> str:
f'emoji={self.emoji!r} default={self.default!r}>'
)

def __str__(self) -> str:
if self.emoji:
base = f'{self.emoji} {self.label}'
else:
base = self.label

if self.description:
return f'{base}\n{self.description}'
return base

@classmethod
def from_dict(cls, data: SelectOptionPayload) -> SelectOption:
try:
Expand Down

0 comments on commit feb0f7f

Please sign in to comment.