aboutsummaryrefslogtreecommitdiff
path: root/discord/message.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-08-23 22:07:29 -0400
committerRapptz <[email protected]>2021-08-23 23:44:20 -0400
commit8bbb8f6db969ba1525083e6d9d8a36d852d6fa81 (patch)
treea0fd580391ea140387bad694e02abd4115ff2c9f /discord/message.py
parentFix message.py typehints (diff)
downloaddiscord.py-8bbb8f6db969ba1525083e6d9d8a36d852d6fa81.tar.xz
discord.py-8bbb8f6db969ba1525083e6d9d8a36d852d6fa81.zip
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.
Diffstat (limited to 'discord/message.py')
-rw-r--r--discord/message.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/discord/message.py b/discord/message.py
index 078aaa76..30eb4990 100644
--- a/discord/message.py
+++ b/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)