Skip to content

Commit 7e4e28f

Browse files
authored
fix: update Discord domain (#43)
1 parent 32d5714 commit 7e4e28f

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/laravel-notification-channels/discord/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/laravel-notification-channels/discord/?branch=master)
99
[![Total Downloads](https://img.shields.io/packagist/dt/laravel-notification-channels/discord.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/discord)
1010

11-
This package makes it easy to send notifications using the [Discord bot API](https://discordapp.com/developers/docs/intro) with Laravel.
11+
This package makes it easy to send notifications using the [Discord bot API](https://discord.com/developers/docs/intro) with Laravel.
1212

1313
## Contents
1414

@@ -46,7 +46,7 @@ Next, you must load the service provider:
4646

4747
### Setting up your Discord bot
4848

49-
1. [Create a Discord application.](https://discordapp.com/developers/applications/me/create)
49+
1. [Create a Discord application.](https://discord.com/developers/applications)
5050
2. Click the `Create a Bot User` button on your Discord application.
5151
3. Paste your bot's API token, found under `App Bot User`, in your `services.php` config file:
5252

@@ -107,7 +107,7 @@ class Guild extends Eloquent
107107
> }
108108
> ```
109109
>
110-
> Please take note that the `getPrivateChannel` method only accepts [Discord's snowflake IDs](https://discordapp.com/developers/docs/reference#snowflakes). There is no API route provided by Discord to lookup a user's ID by their name and tag, and the process for copying and pasting a user ID can be confusing to some users. Because of this, it is recommended to add the option for users to connect their Discord account to their account within your application either by logging in with Discord or linking it to their pre-existing account.
110+
> Please take note that the `getPrivateChannel` method only accepts [Discord's snowflake IDs](https://discord.com/developers/docs/reference#snowflakes). There is no API route provided by Discord to lookup a user's ID by their name and tag, and the process for copying and pasting a user ID can be confusing to some users. Because of this, it is recommended to add the option for users to connect their Discord account to their account within your application either by logging in with Discord or linking it to their pre-existing account.
111111
112112
You may now tell Laravel to send notifications to Discord channels in the `via` method:
113113
@@ -142,8 +142,8 @@ class GameChallengeNotification extends Notification
142142
143143
### Available Message methods
144144

145-
* `body(string)`: Set the content of the message. ([Supports basic markdown](https://support.discordapp.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline-))
146-
* `embed(array)`: Set the embedded content. ([View embed structure](https://discordapp.com/developers/docs/resources/channel#embed-object))
145+
* `body(string)`: Set the content of the message. ([Supports basic markdown](https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline-))
146+
* `embed(array)`: Set the embedded content. ([View embed structure](https://discord.com/developers/docs/resources/channel#embed-object))
147147

148148
## Changelog
149149

src/Commands/SetupCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function handle()
6464
if (! $this->confirm('Is the bot already added to your server?')) {
6565
$clientId = $this->ask('What is your Discord app client ID?');
6666

67-
$this->warn('Add the bot to your server by visiting this link: https://discordapp.com/oauth2/authorize?&client_id='.$clientId.'&scope=bot&permissions=0');
67+
$this->warn('Add the bot to your server by visiting this link: https://discord.com/oauth2/authorize?&client_id='.$clientId.'&scope=bot&permissions=0');
6868

6969
if (! $this->confirm('Continue?', true)) {
7070
return -1;
@@ -81,7 +81,7 @@ public function handle()
8181

8282
// Discord requires all bots to connect via a websocket connection and
8383
// identify at least once before any API requests over HTTP are allowed.
84-
// https://discordapp.com/developers/docs/topics/gateway#gateway-identify
84+
// https://discord.com/developers/docs/topics/gateway#gateway-identify
8585
$client->send(json_encode([
8686
'op' => 2,
8787
'd' => [
@@ -128,7 +128,7 @@ public function getGateway()
128128
$gateway = $this->gateway;
129129

130130
try {
131-
$response = $this->guzzle->get('https://discordapp.com/api/gateway');
131+
$response = $this->guzzle->get('https://discord.com/api/gateway');
132132

133133
$gateway = Arr::get(json_decode($response->getBody(), true), 'url', $gateway);
134134
} catch (Exception $e) {

src/Exceptions/CouldNotSendNotification.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static function serviceRespondedWithAnHttpError(ResponseInterface $respon
3232
*
3333
* @return static
3434
*/
35-
public static function serviceRespondedWithAnApiError(array $response, $code, $exception)
35+
public static function serviceRespondedWithAnApiError(array $response, $code, $exception = null)
3636
{
3737
return new static("Discord responded with an API error: {$response['code']}: {$response['message']}", $code);
3838
}

tests/DiscordChannelTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ public function it_can_send_a_notification()
1717
$http = Mockery::mock(HttpClient::class);
1818
$http->shouldReceive('request')
1919
->once()
20-
->with('POST', 'https://discordapp.com/api/channels/0123456789/messages', [
20+
->with('POST', 'https://discord.com/api/channels/0123456789/messages', [
2121
'headers' => [
2222
'Authorization' => 'Bot super-secret',
2323
],
2424
'json' => ['content' => 'Hello, Discord!', 'embed' => [
2525
'title' => 'Object Title',
26-
'url' => 'https://discordapp.com',
26+
'url' => 'https://discord.com',
2727
]],
2828
])
2929
->andReturn(new Response(200));
@@ -69,7 +69,7 @@ public function toDiscord()
6969
->body('Hello, Discord!')
7070
->embed([
7171
'title' => 'Object Title',
72-
'url' => 'https://discordapp.com',
72+
'url' => 'https://discord.com',
7373
]);
7474
}
7575
}

tests/DiscordTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function it_can_get_a_private_channel_for_a_user()
1919
$http = Mockery::mock(HttpClient::class);
2020
$http->shouldReceive('request')
2121
->once()
22-
->with('POST', 'https://discordapp.com/api/users/@me/channels', [
22+
->with('POST', 'https://discord.com/api/users/@me/channels', [
2323
'headers' => [
2424
'Authorization' => 'Bot super-secret',
2525
],
@@ -41,7 +41,7 @@ public function it_throws_an_exception_when_it_receives_an_http_error()
4141
$http = Mockery::mock(HttpClient::class);
4242
$http->shouldReceive('request')
4343
->once()
44-
->with('POST', 'https://discordapp.com/api/channels/some-channel-id/messages', [
44+
->with('POST', 'https://discord.com/api/channels/some-channel-id/messages', [
4545
'headers' => [
4646
'Authorization' => 'Bot super-secret',
4747
],
@@ -63,7 +63,7 @@ public function it_throws_an_exception_when_it_could_not_talk_to_discord()
6363
$http = Mockery::mock(HttpClient::class);
6464
$http->shouldReceive('request')
6565
->once()
66-
->with('POST', 'https://discordapp.com/api/channels/some-channel-id/messages', [
66+
->with('POST', 'https://discord.com/api/channels/some-channel-id/messages', [
6767
'headers' => [
6868
'Authorization' => 'Bot super-secret',
6969
],
@@ -85,7 +85,7 @@ public function it_wraps_and_rethrows_a_caught_exception()
8585
$http = Mockery::mock(HttpClient::class);
8686
$http->shouldReceive('request')
8787
->once()
88-
->with('POST', 'https://discordapp.com/api/channels/some-channel-id/messages', [
88+
->with('POST', 'https://discord.com/api/channels/some-channel-id/messages', [
8989
'headers' => [
9090
'Authorization' => 'Bot super-secret',
9191
],
@@ -107,7 +107,7 @@ public function it_throws_an_exception_if_the_api_responds_with_an_error()
107107
$http = Mockery::mock(HttpClient::class);
108108
$http->shouldReceive('request')
109109
->once()
110-
->with('POST', 'https://discordapp.com/api/channels/some-channel-id/messages', [
110+
->with('POST', 'https://discord.com/api/channels/some-channel-id/messages', [
111111
'headers' => [
112112
'Authorization' => 'Bot super-secret',
113113
],

tests/SetupCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function it_tells_the_user_to_connect_the_bot_to_their_discord_server()
3535

3636
$command->shouldReceive('confirm')->with('Is the bot already added to your server?')->once()->andReturn(false);
3737
$command->shouldReceive('ask')->with('What is your Discord app client ID?')->once()->andReturn('my-client-id');
38-
$command->shouldReceive('warn')->with('Add the bot to your server by visiting this link: https://discordapp.com/oauth2/authorize?&client_id=my-client-id&scope=bot&permissions=0');
38+
$command->shouldReceive('warn')->with('Add the bot to your server by visiting this link: https://discord.com/oauth2/authorize?&client_id=my-client-id&scope=bot&permissions=0');
3939
$command->shouldReceive('confirm')->with('Continue?', true)->once()->andReturn(false);
4040

4141
$this->app[Kernel::class]->registerCommand($command);
@@ -59,7 +59,7 @@ public function it_fetches_the_websocket_gateway_url()
5959
{
6060
$http = Mockery::mock(HttpClient::class);
6161

62-
$http->shouldReceive('get')->with('https://discordapp.com/api/gateway')->once()->andReturn(new Response(200, [], json_encode(['url' => 'wss://test-gateway.discord.gg'])));
62+
$http->shouldReceive('get')->with('https://discord.com/api/gateway')->once()->andReturn(new Response(200, [], json_encode(['url' => 'wss://test-gateway.discord.gg'])));
6363

6464
$command = new SetupCommand($http, 'my-token');
6565

@@ -73,7 +73,7 @@ public function it_returns_a_default_websocket_gateway_url()
7373
{
7474
$http = Mockery::mock(HttpClient::class);
7575

76-
$http->shouldReceive('get')->with('https://discordapp.com/api/gateway')->once()->andThrow(new RequestException('Not found', Mockery::mock(Request::class), new Response(404, [], json_encode(['message' => 'Not found']))));
76+
$http->shouldReceive('get')->with('https://discord.com/api/gateway')->once()->andThrow(new RequestException('Not found', Mockery::mock(Request::class), new Response(404, [], json_encode(['message' => 'Not found']))));
7777

7878
$command = Mockery::mock(SetupCommand::class.'[warn]', [$http, 'my-token']);
7979

@@ -136,7 +136,7 @@ public function it_notifies_the_user_of_a_failed_identification_attempt()
136136

137137
$command->shouldReceive('confirm')->with('Is the bot already added to your server?')->once()->andReturn(false);
138138
$command->shouldReceive('ask')->with('What is your Discord app client ID?')->once()->andReturn('my-client-id');
139-
$command->shouldReceive('warn')->with('Add the bot to your server by visiting this link: https://discordapp.com/oauth2/authorize?&client_id=my-client-id&scope=bot&permissions=0');
139+
$command->shouldReceive('warn')->with('Add the bot to your server by visiting this link: https://discord.com/oauth2/authorize?&client_id=my-client-id&scope=bot&permissions=0');
140140
$command->shouldReceive('confirm')->with('Continue?', true)->once()->andReturn(true);
141141
$command->shouldReceive('warn')->with("Attempting to identify the bot with Discord's websocket gateway...")->once();
142142
$command->shouldReceive('getGateway')->once()->andReturn('wss://gateway.discord.gg');

0 commit comments

Comments
 (0)