All Projects → awssat → discord-notification-channel

awssat / discord-notification-channel

Licence: MIT license
Laravel Notification Channel for Discord ! 💬️🗨️

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to discord-notification-channel

laravel-cms
Juzaweb CMS is a Content Management System (CMS) developed based on Laravel Framework and web platform whose sole purpose is to make your development workflow simple again. Project develop by Juzaweb
Stars: ✭ 15 (-82.56%)
Mutual labels:  laravel-packages
laravel-crud-generator
Laravel CRUD Generator
Stars: ✭ 181 (+110.47%)
Mutual labels:  laravel-packages
laravel-user-review
This package uses a trait for a model which can be reviewable by users and give starred/point ratings and only one reply can come from admin as a support response. (like Google playstore review system). This package can be used with any projects like Ecommerce, Shop, Store, etc models
Stars: ✭ 22 (-74.42%)
Mutual labels:  laravel-packages
laravel-route-blocker
Block routes by IP
Stars: ✭ 77 (-10.47%)
Mutual labels:  laravel-packages
tinker-zero
Bridge laravel/tinker for your laravel-zero applications
Stars: ✭ 39 (-54.65%)
Mutual labels:  laravel-packages
Deletediscordmessages
Undiscord - Delete all messages in a Discord channel or DM (Easy and fast) Bulk delete
Stars: ✭ 2,555 (+2870.93%)
Mutual labels:  discord-channel
deleteDiscordMessages
Delete all messages in a Discord channel or DM (Easy and fast) Bulk delete
Stars: ✭ 40 (-53.49%)
Mutual labels:  discord-channel

Laravel Discord Notification Channel

Introduction

Send Discord messages through webhook with Discord or Slack payload via Laravel Notifications channels

Features

  • Support slack payload by using new (new SlackMessage) or $this->toSlack($notifiable)
  • Support discord webhook payload
  • Easy to use

Install

Via Composer

composer require awssat/discord-notification-channel

Usage

in your notification you should define the discord channel in the via method

public function via($notifiable)
{
    return ['mail', 'discord'];
}

you should have a toDiscord method

    public function toDiscord($notifiable)
    {
        return (new DiscordMessage)
            ->from('Laravel')
            ->content('Content')
            ->embed(function ($embed) {
                $embed->title('Discord is cool')->description('Slack nah')
                    ->field('Laravel', '9.0.0', true)
                    ->field('PHP', '8.0.0', true);
            });
    }

toDiscord method can receive DiscordMessage or SlackMessage

Example of slack message

    public function toDiscord($notifiable)
    {
        return (new SlackMessage)
                ->content('One of your invoices has been paid!');
    }

or if you want you can make it run from toSlack method

    public function toSlack($notifiable)
    {
        return (new SlackMessage)
                ->content('One of your invoices has been paid!');
    }

    public function toDiscord($notifiable)
    {
        return $this->toSlack($notifiable);
    }

https://laravel.com/docs/6.x/notifications#slack-notifications for further laravel slack messages examples

Routing Discord Notifications

To route Discord notifications to the proper location, define a routeNotificationForDiscord method on your notifiable entity. This should return the webhook URL to which the notification should be delivered. read Webhook Discord docs here https://support.discordapp.com/hc/en-us/articles/228383668-Intro-to-Webhooks

<?php

namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

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/.......';
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].