Add support for poll result messages

This commit is contained in:
DA344
2025-01-19 11:09:05 +01:00
committed by GitHub
parent ff2ad34be5
commit afbbc07e98
7 changed files with 136 additions and 5 deletions

View File

@ -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 ''