mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-04 08:56:19 +00:00
Add support for poll result messages
This commit is contained in:
@ -2268,6 +2268,13 @@ class Message(PartialMessage, Hashable):
|
||||
# the channel will be the correct type here
|
||||
ref.resolved = self.__class__(channel=chan, data=resolved, state=state) # type: ignore
|
||||
|
||||
if self.type is MessageType.poll_result:
|
||||
if isinstance(self.reference.resolved, self.__class__):
|
||||
self._state._update_poll_results(self, self.reference.resolved)
|
||||
else:
|
||||
if self.reference.message_id:
|
||||
self._state._update_poll_results(self, self.reference.message_id)
|
||||
|
||||
self.application: Optional[MessageApplication] = None
|
||||
try:
|
||||
application = data['application']
|
||||
@ -2634,6 +2641,7 @@ class Message(PartialMessage, Hashable):
|
||||
MessageType.chat_input_command,
|
||||
MessageType.context_menu_command,
|
||||
MessageType.thread_starter_message,
|
||||
MessageType.poll_result,
|
||||
)
|
||||
|
||||
@utils.cached_slot_property('_cs_system_content')
|
||||
@ -2810,6 +2818,14 @@ class Message(PartialMessage, Hashable):
|
||||
if guild_product_purchase is not None:
|
||||
return f'{self.author.name} has purchased {guild_product_purchase.product_name}!'
|
||||
|
||||
if self.type is MessageType.poll_result:
|
||||
embed = self.embeds[0] # Will always have 1 embed
|
||||
poll_title = utils.get(
|
||||
embed.fields,
|
||||
name='poll_question_text',
|
||||
)
|
||||
return f'{self.author.display_name}\'s poll {poll_title.value} has closed.' # type: ignore
|
||||
|
||||
# Fallback for unknown message types
|
||||
return ''
|
||||
|
||||
|
Reference in New Issue
Block a user