Discord Notifications
You can send notifications to Discord or Slack by wiring hooks to a webhook URL. Use this page for basic team alerts.
Example plugin
<?php
use Kirby\Http\Remote;
Kirby::plugin('klub/discord', [
'options' => [
'webhook' => '',
],
'hooks' => [
'klub.member.created' => function ($user) {
site()->discord([
'content' => 'New member: '.$user->nameOrEmail(),
]);
},
],
'siteMethods' => [
'discord' => function (array $payload): bool {
$webhook = option('klub.discord.webhook');
if (! $webhook) {
return false;
}
$response = Remote::post($webhook, [
'headers' => [
'Accept' => 'application/json',
'Accept-Charset' => 'utf-8',
],
'data' => $payload,
]);
return $response->code() === 204;
},
],
]);