1 | <?php |
||
11 | class Discord |
||
12 | { |
||
13 | /** |
||
14 | * Discord API base URL. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $baseUrl = 'https://discordapp.com/api'; |
||
19 | |||
20 | /** |
||
21 | * API HTTP client. |
||
22 | * |
||
23 | * @var \GuzzleHttp\Client |
||
24 | */ |
||
25 | protected $httpClient; |
||
26 | |||
27 | /** |
||
28 | * Discord API token. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $token; |
||
33 | |||
34 | /** |
||
35 | * @param \GuzzleHttp\Client $http |
||
36 | * @param string $token |
||
37 | */ |
||
38 | public function __construct(HttpClient $http, $token) |
||
43 | |||
44 | /** |
||
45 | * Send a message to a Discord channel. |
||
46 | * |
||
47 | * @param string $channel |
||
48 | * @param array $data |
||
49 | * |
||
50 | * @return array |
||
51 | */ |
||
52 | public function send($channel, array $data) |
||
56 | |||
57 | /** |
||
58 | * Create and/or get a private channel with a Discord user. |
||
59 | * |
||
60 | * @param mixed $user |
||
61 | * |
||
62 | * @return string |
||
63 | */ |
||
64 | public function getPrivateChannel($user) |
||
68 | |||
69 | /** |
||
70 | * Perform an HTTP request with the Discord API. |
||
71 | * |
||
72 | * @param string $verb |
||
73 | * @param string $endpoint |
||
74 | * @param array $data |
||
75 | * |
||
76 | * @return array |
||
77 | * |
||
78 | * @throws \NotificationChannels\Discord\Exceptions\CouldNotSendNotification |
||
79 | */ |
||
80 | protected function request($verb, $endpoint, array $data) |
||
109 | } |
||
110 |