diff options
| author | Rapptz <[email protected]> | 2021-08-23 22:07:29 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2021-08-23 23:44:20 -0400 |
| commit | 8bbb8f6db969ba1525083e6d9d8a36d852d6fa81 (patch) | |
| tree | a0fd580391ea140387bad694e02abd4115ff2c9f /discord/message.py | |
| parent | Fix message.py typehints (diff) | |
| download | discord.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.py | 3 |
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) |