Data source: Discord


1Presentation

Discord is a communication service initially dedicated to gamers, and whose use has since expanded.

It is possible to send messages within a communication channel, to notify users in an automated way.

If you have correctly configured the iDiscord connection parameters, Temma automatically creates an object of type \Temma\Datasources\Discord, with which you can send notifications. By convention, we'll assume that you've named this connection disc in the etc/temma.php file (see configuration documentation).

In the controllers, the Discord connection is then available by writing:

$this->disc

In other objects managed by the dependency injection component, the Pushover connection is accessible by writing:

$this->_loader->dataSources['disc']

2Configuration

To send messages to Discord, you must first create a webhook. Each webhook is linked to a channel in which it can post messages.

In the etc/temma.php file (see configuration documentation), you declare the DSN (Data Source Name) used to connect to Discord.

The DSN used to connect to Discord can be written as discord://WEBHOOK

With WEBHOOK the value of the webhook URL, without the https:// prefix.
Example: discord.com/api/webhooks/ABC/XYZ


3Notification content

Notifications can contain text (up to 2000 characters), which accepts a derivative of Markdown syntax.


4Unified calls

4.1Array-like access

// send a simple message
$this->disc[''] = "Message to send";

4.2Advanced method

// send a simple message
$this->disc->set('', "Message to send");