Skip to content

Commit e6f0b31

Browse files
committed
Add rich type webhook docs
1 parent 2402165 commit e6f0b31

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

notifier/chatters.rst

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ you to send messages to chat services like Slack or Telegram::
4646
Adding Interactions to a Slack Message
4747
--------------------------------------
4848

49-
With a Slack message, you can use the
49+
With a Slack message, you can use the
5050
:class:`Symfony\\Component\\Notifier\\Bridge\\Slack\\SlackOptions` to add
5151
some interactive options called `Block elements`_::
5252

@@ -91,3 +91,56 @@ some interactive options called `Block elements`_::
9191
$chatter->send($chatMessage);
9292

9393
.. _`Block elements`: https://api.slack.com/reference/block-kit/block-elements
94+
95+
Adding Interactions to a Discord Message
96+
--------------------------------------
97+
98+
With a Discord message, you can use the
99+
:class:`Symfony\\Component\\Notifier\\Bridge\\Discord\\DiscordOptions` to add
100+
some interactive options called `Embed elements`_::
101+
102+
use Symfony\Component\Notifier\Bridge\Discord\Block\DiscordEmbed;
103+
use Symfony\Component\Notifier\Bridge\Discord\Block\DiscordFieldEmbedObject;
104+
use Symfony\Component\Notifier\Bridge\Discord\Block\DiscordFooterEmbedObject;
105+
use Symfony\Component\Notifier\Bridge\Discord\Block\DiscordMediaEmbedObject;
106+
use Symfony\Component\Notifier\Bridge\Discord\DiscordOptions;
107+
use Symfony\Component\Notifier\Message\ChatMessage;
108+
109+
$chatMessage = new ChatMessage('');
110+
111+
// Create Discord Embed
112+
$discordOptions = (new DiscordOptions())
113+
->username('connor bot')
114+
->addEmbed((new DiscordEmbed())
115+
->color(2021216)
116+
->title('New song added!')
117+
->thumbnail((new DiscordMediaEmbedObject())
118+
->url('https://i.scdn.co/image/ab67616d0000b2735eb27502aa5cb1b4c9db426b'))
119+
->addField((new DiscordFieldEmbedObject())
120+
->name('Track')
121+
->value('[Common Ground](https://open.spotify.com/track/36TYfGWUhIRlVjM8TxGUK6)')
122+
->inline(true)
123+
)
124+
->addField((new DiscordFieldEmbedObject())
125+
->name('Artist')
126+
->value('Alasdair Fraser')
127+
->inline(true)
128+
)
129+
->addField((new DiscordFieldEmbedObject())
130+
->name('Album')
131+
->value('Dawn Dance')
132+
->inline(true)
133+
)
134+
->footer((new DiscordFooterEmbedObject())
135+
->text('Added ...')
136+
->iconUrl('https://upload.wikimedia.org/wikipedia/commons/thumb/1/19/Spotify_logo_without_text.svg/200px-Spotify_logo_without_text.svg.png')
137+
)
138+
)
139+
;
140+
141+
// Add the custom options to the chat message and send the message
142+
$chatMessage->options($discordOptions);
143+
144+
$chatter->send($chatMessage);
145+
146+
.. _`Embed elements`: https://discord.com/developers/docs/resources/webhook

0 commit comments

Comments
 (0)