noynac/phpcord-webhooks

A PHP wrapper for using Discord's webhook API

v1.0.0 2021-05-17 00:42 UTC

This package is not auto-updated.

Last update: 2024-10-01 15:01:38 UTC


README

Software License

This is a small WIP library for using discord webhooks.

Install

composer require noynac/phpcord-webhooks

Usage

require_once "vendor/autoload.php";

use DiscordWebhook\Message;
use DiscordWebhook\Embed;

$webhook = 'YOUR-WEBHOOK-URL-HERE';

$message = new Message();
$message->setWebhook($webhook)
    ->setMessage("some message")
    ->setUsername("username here");

$newEmbed = new Embed();
$newEmbed->setColor('1000')
	->setTitle('Some title')
	->setURL('https://github.com/Sooshiii/phpcord-webhooks')
	->setAuthor('Some name', 'https://i.imgur.com/EJOjIMC.jpg')
	->setDescription('Some description here')
	->setThumbnail('https://i.imgur.com/EJOjIMC.jpg')
	->addField('Inline field title', 'Some value here', true)
	->setImage('https://i.imgur.com/EJOjIMC.jpg')
	->setTimestamp()
	->setFooter('Some footer text here', 'https://i.imgur.com/EJOjIMC.jpg');
      
$message->addEmbed($newEmbed);

$message->send();

Testing

$ phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.