/** * Broadcasts that you are typing to the channel. Lasts for 5 seconds. * * @return boolean */ public function broadcastTyping() { if ($this->type != self::TYPE_TEXT) { return false; } Guzzle::post("channels/{$this->id}/typing"); return true; }
/** * Accepts a Discord channel invite. * * @param $code * * @return Invite * @throws InviteInvalidException */ public function acceptInvite($code) { try { $request = Guzzle::post("invite/{$code}"); } catch (\Exception $e) { throw new InviteInvalidException('The invite is invalid or has expired.'); } return new Invite(['code' => $request->code, 'guild' => $request->guild, 'xkcdpass' => $request->xkcdpass, 'channel' => $request->channel], true); }
/** * Broadcasts that you are typing to the channel. Lasts for 5 seconds. * * @return boolean */ public function broadcastTyping() { if (isset($this->attributes_cache['channel_id'])) { $channel_id = $this->attributes_cache['channel_id']; } else { $channel = Guzzle::post('users/@me/channels', ['recipient_id' => $this->id]); $channel_id = $channel->id; $this->attributes_cache['channel_id'] = $channel->id; } Guzzle::post("channels/{$channel_id}/typing"); return true; }
/** * Saves the part to the Discord servers. * * @return boolean */ public function save() { $attributes = $this->created ? $this->getUpdatableAttributes() : $this->getCreatableAttributes(); try { if ($this->created) { if (!$this->editable) { return false; } $request = Guzzle::patch($this->replaceWithVariables($this->uris['update']), $attributes); } else { if (!$this->creatable) { return false; } $request = Guzzle::post($this->replaceWithVariables($this->uris['create']), $attributes); $this->created = true; $this->deleted = false; } } catch (\Exception $e) { throw new PartRequestFailedException($e->getMessage()); } if ($this->fillAfterSave) { $this->fill($request); } return true; }