From ee50c812eee04bd35768e69861700b814aa207ee Mon Sep 17 00:00:00 2001 From: Gracie <87055757+Grace-codes@users.noreply.github.com> Date: Sat, 11 Sep 2021 14:55:58 +0530 Subject: [PATCH] Add a dunder len to Message --- discord/message.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/discord/message.py b/discord/message.py index 304c807da4..49d0cce187 100644 --- a/discord/message.py +++ b/discord/message.py @@ -502,7 +502,11 @@ class Message(Hashable): .. describe:: hash(x) Returns the message's hash. - + + .. describe:: len(x) + + Returns the length of the message's content. + Attributes ----------- tts: :class:`bool` @@ -712,6 +716,9 @@ def __repr__(self) -> str: f'<{name} id={self.id} channel={self.channel!r} type={self.type!r} author={self.author!r} flags={self.flags!r}>' ) + def __len__(self): + return len(self.content) + def _try_patch(self, data, key, transform=None) -> None: try: value = data[key]