Skip to content

Commit 4622773

Browse files
Fixed creating message with no self-member cached (#523)
Closes #522
1 parent df95ddd commit 4622773

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/Discord/Parts/Channel/Channel.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,8 @@ public function sendMessage(string $text, bool $tts = false, $embed = null, $all
704704
];
705705
}
706706

707-
if (! $this->is_private) {
708-
$botperms = $this->guild->members->offsetGet($this->discord->id)->getPermissions($this);
707+
if (! $this->is_private && $member = $this->guild->members->offsetGet($this->discord->id)) {
708+
$botperms = $member->getPermissions($this);
709709

710710
if (! $botperms->send_messages) {
711711
return \React\Promise\reject(new NoPermissionsException('You do not have permission to send messages in the specified channel.'));

src/Discord/Parts/Channel/Message.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,7 @@ protected function getAuthorAttribute(): ?Part
322322
*/
323323
protected function getMemberAttribute(): ?Member
324324
{
325-
if (($this->channel->guild &&
326-
$author = $this->channel->guild->members->get('id', $this->attributes['author']->id)) ||
327-
$author = $this->discord->users->get('id', $this->attributes['author']->id)
328-
) {
325+
if ($this->channel->guild && $author = $this->channel->guild->members->get('id', $this->attributes['author']->id)) {
329326
return $author;
330327
}
331328

0 commit comments

Comments
 (0)