Browse Source

Use getattr for default_auto_archive_duration in Message.create_thread

Some channel types do not have this attribute so a fallback is
necessary to prevent the attribute access from erroring.
pull/7476/head
Rapptz 4 years ago
parent
commit
8bbb8f6db9
  1. 3
      discord/message.py

3
discord/message.py

@ -1527,11 +1527,12 @@ class Message(Hashable):
if self.guild is None:
raise InvalidArgument('This message does not have guild info attached.')
default_auto_archive_duration: ThreadArchiveDuration = getattr(self.channel, 'default_auto_archive_duration', 1440)
data = await self._state.http.start_thread_with_message(
self.channel.id,
self.id,
name=name,
auto_archive_duration=auto_archive_duration or self.channel.default_auto_archive_duration,
auto_archive_duration=auto_archive_duration or default_auto_archive_duration,
)
return Thread(guild=self.guild, state=self._state, data=data)

Loading…
Cancel
Save