-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add support for message call #9911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Rapptz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly okay, I'd prefer consistency with the previous version.
The previous name was CallMessage and not MessageCall. I still think that name makes more sense than the current one because Call is the adjective for Message, similar to PartialMessage rather than MessagePartial.
|
I think |
yes you're right, it currently returns an empty string. |
|
The problem about this is: I don't know e.g. when Discord uses the next hour. When is it |
|
You can see the previous implementation: Lines 319 to 330 in 1863a1c
However it's pretty out-of-date. From the client, the strings are as follows: The client formats the duration string like this... m = function(e) {
let t = null != e.call ? e.call.duration : null;
return null != t ? t.humanize() : null
}(t);Which isn't very helpful. We can just take your liberty here and just round, so 2.5 hours => 3 hours but 2.3 hours => 2 hours. Less than 1 hour would be in minutes (so 59 minutes is possible instead of rounding to an hour). The skeleton should be something like this: if self.type is MessageType.call:
call_ended = self.call.ended_timestamp is not None
missed = self._state.user not in self.call.participants
if call_ended:
duration = ...
if missed:
return 'You missed a call from {0.author.name} that lasted {1}'.format(self, duration)
else:
return '{0.author.name} started a call that lasted {1}.'.format(self, duration)
else:
if missed:
return '{0.author.name} started a call \N{EM DASH} Join the call.'.format(self)
else:
return '{0.author.name} started a call.'.format(self) |
|
I've just noted that So we have to retrieve the users directly from the cache. |
|
I've added the system call message. The "calculation" is based on how Discord determines it (approx.). I've manipulated the message object in the client to see what the output is. I also made some unit tests, which can be found here: |
Summary
This PR adds support for the message call object.
Related PR:
Checklist