Moodle Discord integration

Re: Moodle Discord integration

by Francis Devine -
Number of replies: 0
Picture of Core developers
Hi Tiago

I've implemented similar types of things before, but the local_webhooks plugin looks like it would work for the use case, although you would need to extend it to support the discord authentication.

more generically you can listen to events by subscribing to specific events in a plugin
https://docs.moodle.org/dev/Events_API

I'd then use the event listener to generate an adhoc task - https://docs.moodle.org/dev/Task_API#Adhoc_tasks (you want the event listeners to do as little as possible so they're fast, as they are called quite often and during the users session, the adhoc task will run in the background cron and therefore has the luxury of time, at the cost of a little latency of having to wait for the next cron run. Which on a modern site should be running at least every minute).

That adhoc task would then be responsible for calling the relevant discord webhook.


The tool trigger plugin does very similar things - https://moodle.org/plugins/tool_trigger so you may be able to browse the source for that https://github.com/catalyst/moodle-tool_trigger to get an idea of the code required.