Updated 22 April 2020
Discord is a video/audio calling VoIP application. Discord is free and created for video game communities.
It does not only provide audio or video chat feature but also specialises in text and image in chat channels.
In discord you can make various servers containing particular channels for different tasks ie. for playing different games with your squad or listening music or join afk channels of a server if you are simply AFK.
Installation of this package is very easy. What you need to do is to follow this simple command:
1 |
composer require awssat/discord-notification-channel |
One must define the discord method in the notification channel.
1 2 3 4 |
public function via($notifiable) { return ['mail', 'discord']; } |
Now, create a toDiscord() method
1 2 3 4 5 6 7 8 9 10 11 |
public function toDiscord($notifiable) { return (new DiscordMessage) ->from('Laravel') ->content('Content') ->embed(function ($embed) { $embed->title('Discord is cool')->description('Slack nah') ->field('Laravel', '7.0.0', true) ->field('PHP', '8.0.0', true); }); } |
To route Discord notifications to the proper location, define a routeNotificationForDiscord method on your notifiable entity.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
class User extends Authenticatable { use Notifiable; /** * Route notifications for the Discord channel. * * @param \Illuminate\Notifications\Notification $notification * @return string */ public function routeNotificationForDiscord($notification) { return 'https://discordapp.com/api/webhooks/.......'; } } |
That’s it, you are done now. You can send the notification to the discord channels from your laravel application.
Source: Github of Laravel discord notification channel Git repository
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.