2017 © Pedro Peláez
 

library discord-webhooks

A fork from nopjmp/discord-webhooks

image

labymod/discord-webhooks

A fork from nopjmp/discord-webhooks

  • Thursday, April 12, 2018
  • by Scrummer
  • Repository
  • 0 Watchers
  • 4 Stars
  • 364 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 11 Forks
  • 0 Open issues
  • 8 Versions
  • 6 % Grown

The README.md

discord-webhooks

Discord webhooks is a simple client for Discord's webhook API., (*1)

Motivation

While this is probably "yet another" library for Discord's webhook system, I wanted to make my own. Discord doesn't support BitBucket's webhook system and the Slack compatible endpoint doesn't send a message., (*2)

Getting Started

You can either copy the PHP file directly into your project or preferable just use composer., (*3)

Composer require command

composer require nopjmp/discord-webhooks, (*4)

Usage

It is fairly easy to use. I'll throw in an example., (*5)

<?php

use \Discord\Webhook;
use \Discord\Embed;

$webhook = new Webhook( 'DISCORD_WEBHOOK_URL' );
$embed = new Embed();

$embed->setDescription( 'This is an embed' );

$webhook->setUsername( 'Bot' )->setMessage( 'Hello, Human!' )->setEmbed( $embed )->send();

Here is another example. Let's send some files., (*6)

$webhook = new Webhook( 'DISCORD_WEBHOOK_URL' );
$file = new File( "filename.jpg", "postname.jpg"/*optional*/ );

$webhook
    ->setUsername( 'Bot' ) /*optional*/
    ->setAvatar( 'https://example.com/bot.jpg' ) /*optional*/
    ->setMessage( 'Hello, Human!' ) /*optional*/
    ->setFile( $file )
    ->send();

To style your embeds properly, you can have a look at this website: https://cog-creators.github.io/discord-embed-sandbox/\ Maybe the site can help you structuring your embeds properly ;), (*7)

Advanced example

Now let's create a cool embed like this:\ , (*8)

Aaaaaand here's the code:, (*9)

<?php

use Discord\Webhook;

$wh = new Webhook( 'YOUR_WEBHOOK_URL' );
$embed = new \Discord\Embed();
$thumbnail = new \Discord\Embed\EmbedThumbnail();
$author = new \Discord\Embed\EmbedAuthor();
$field1 = new \Discord\Embed\EmbedField();
$field2 = new \Discord\Embed\EmbedField();
$field3 = new \Discord\Embed\EmbedField();
$footer = new \Discord\Embed\EmbedFooter();

$thumbnail->setUrl( 'https://pbs.twimg.com/media/C--1DR0UIAEr6Bw.png' );
$author
    ->setName( 'Discord' )
    ->setIconUrl( 'https://discordapp.com/assets/28174a34e77bb5e5310ced9f95cb480b.png' )
    ->setUrl( 'https://discordapp.com/' );
$field1
    ->setName( 'Field 1' )
    ->setValue( 'Some cool text' )
    ->setInline( true );
$field2
    ->setName( 'Field 2' )
    ->setValue( 'Another cool text' )
    ->setInline( true );
$field3
    ->setName( 'Field 3' )
    ->setValue( 'A full width field where I can write some more text' );
$footer->setText( 'Here goes the footer' );
$embed
    ->setTitle( 'This is my title' )
    ->setDescription( 'Another fancy description' )
    ->setColor( 15158332 )
    ->setThumbnail( $thumbnail )
    ->setAuthor( $author )
    ->setField( $field1 )
    ->setField( $field2 )
    ->setField( $field3 )
    ->setFooter( $footer );

$wh
    ->setUsername( 'Fancy Bot' )
    ->setAvatar( 'https://pbs.twimg.com/media/C51iiP9UYAIPpWP.png' )
    ->setEmbed( $embed )
    ->send();

Here's the official color list to colorize your embeds:, (*10)

DEFAULT: 0,
AQUA: 1752220,
GREEN: 3066993,
BLUE: 3447003,
PURPLE: 10181046,
GOLD: 15844367,
ORANGE: 15105570,
RED: 15158332,
GREY: 9807270,
DARKER_GREY: 8359053,
NAVY: 3426654,
DARK_AQUA: 1146986,
DARK_GREEN: 2067276,
DARK_BLUE: 2123412,
DARK_PURPLE: 7419530,
DARK_GOLD: 12745742,
DARK_ORANGE: 11027200,
DARK_RED: 10038562,
DARK_GREY: 9936031,
LIGHT_GREY: 12370112,
DARK_NAVY: 2899536

License

The project is MIT licensed. To read the full license, open LICENSE.md., (*11)

Contributing

Pull requests and issues are open!, (*12)

The Versions

12/04 2018

dev-master

9999999-dev

A fork from nopjmp/discord-webhooks

  Sources   Download

MIT

The Requires

  • ext-curl *
  • php >=5.4

 

by Kyle Thompson
by Avatar Scrummer

02/11 2017

1.1.1

1.1.1.0

A fork from nopjmp/discord-webhooks

  Sources   Download

MIT

The Requires

  • ext-curl *
  • php >=5.4

 

by Kyle Thompson
by Avatar Scrummer

01/11 2017

1.1.0

1.1.0.0

A fork from nopjmp/discord-webhooks

  Sources   Download

MIT

The Requires

  • ext-curl *
  • php >=5.4

 

by Kyle Thompson
by Avatar Scrummer

29/10 2017

1.0.1

1.0.1.0

A fork from nopjmp/discord-webhooks

  Sources   Download

MIT

The Requires

  • ext-curl *
  • php >=5.4

 

by Kyle Thompson
by Avatar Scrummer

29/10 2017

1.0

1.0.0.0

A fork from nopjmp/discord-webhooks

  Sources   Download

MIT

The Requires

  • ext-curl *
  • php >=5.4

 

by Kyle Thompson
by Avatar Scrummer

27/06 2017

0.2.2

0.2.2.0

A simple Discord webhook client library.

  Sources   Download

MIT

The Requires

  • ext-curl *
  • php >=5.4

 

by Kyle Thompson

11/01 2017

0.2.1

0.2.1.0

A simple Discord webhook client library.

  Sources   Download

MIT

The Requires

  • ext-curl *
  • php >=5.4

 

by Avatar nopjmp

11/01 2017

0.2

0.2.0.0

A simple Discord webhook client library.

  Sources   Download

MIT

The Requires

  • ext-curl *
  • php >=5.4

 

by Avatar nopjmp