PHP code example of getkirby / discord

1. Go to this page and download the library: Download getkirby/discord library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

getkirby / discord example snippets


use Kirby\Discord\Discord;

Discord::submit(
  webhook: 'https://discord.com/api/webhooks/xxx/xxx',
  username: 'kirbybot',
  avatar: 'https://example.com/avatar.jpg',
  title: '🔥 Message Title',
  color: '#ebc747',
  description: 'Here goes some nice text',
  author: [
    'name' => 'Ron Swanson',
    'url'  => 'https://example.com',
    'icon' => 'https://example.com/someicon.png'
  ],
  fields: [
    [
      'name'  => 'This is a custom field',
      'value' => 'Add any value here'
    ],
    [
      'name'  => 'This is another one',
      'value' => 'https://canbeanurl.com'
    ],
  ],
  footer: 'Some text for the footer'
);

// site/config/config.mydomain.com.php
return [
  'discord' [
    'mywebhook' => 'https://discord.com/api/webhooks/xxx/xxx'
  ]
];

Discord::submit(
  webhook: option('discord.mywebhook'),
  // see additional params above
);