Okay I figured it out in the end. For anyone finding this in the future maybe this will help, In my class "DeleteFiles" I make a subscription function:
use Illuminate\Contracts\Events\Dispatcher;
use Flarum\Post\Event\Deleting;
public function subscribe(Dispatcher $events) {
$events->listen(Deleting::class, [$this, 'deletingPost']);
}
and the extend.php file returns this class like this:
use ruanha-or-your-own-vendor-name\DeleteFiles\DeleteFiles;
return [
function (Dispatcher $events) {
$events->subscribe(DeleteFiles::class);
},
];