Skip to content

A composer package for creating discord webhooks

License

Notifications You must be signed in to change notification settings

dc-Ragnarok/Gjallarbru

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Package for creating discord webhooks

Requirements

  • PHP 8.1=<
  • Composer 2
  • Basic PHP OOP Knowledge
  • Basic Knowledge on discord webhooks

Basic Example

$webhook = new Webhook("https://discord.com/api/webhooks/xxxxxx/xxxxxx");

$webhook->setContent("Hello world!")->send();

Basic Embedded Example

$webhook
    ->addEmbeds(Embed::new()
        ->setTitle("Basic Embed")
        ->setDescription("A basic embedded message")
        ->setColor("#8800FF")
        ->addFields(
            Field::new()
                ->setName("Field 1")
                ->setValue("Field 2"),
            Field::new()
                ->setName("Field 2")
                ->setValue("Field 2"),
            Field::new()
                ->setName("Field 3")
                ->setValue("Field 3")
        )
    )
    ->send()
;

Uploading Files

$webhook
    ->addFile("/path/to/file")
    ->send()
;

Sending Webhook to Thread

$webhook
    ->addQueryParam(QueryParamTypes::THREAD_ID, "<thread_id>")
    // ...
;

or

$webhook = new Webhook("https://discord.com/api/webhooks/xxxxxx/xxxxxx", "<thread_id>");