コード例 #1
0
ファイル: Channel.php プロジェクト: silentgecko/DiscordPHP
 /**
  * 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;
 }
コード例 #2
0
ファイル: Discord.php プロジェクト: silentgecko/DiscordPHP
 /**
  * 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);
 }
コード例 #3
0
ファイル: User.php プロジェクト: shellbot/DiscordPHP
 /**
  * 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;
 }
コード例 #4
0
ファイル: Part.php プロジェクト: jamiebatch452/DiscordPHP
 /**
  * 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;
 }