I'm not sure where you saw that the "DiscardVirtualMemory" function "should exist on 8.1 and higher."
According to https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-discardvirtualmemory the "Minimum Supported Client" for the DiscardVirtualMemory function is Windows 8.1 Update, but that doesn't mean that the function is in the Windows 8.1 version of kernel32.dll.
It's not there in my installation of Windows 8.1. If you want to check your own system, get Nirsoft's DLL Export Viewer: https://www.nirsoft.net/utils/dll_export_viewer.html (see screenshot below, which is looking at kernel32.dll from C:\Windows\System32 on an up-to-date Windows 8.1 system).
I don't know how definitive this site is, but it says that DiscardVirtualMemory is only available in kernel32.dll for Windows 10 and above: https://www.geoffchappell.com/studies/windows/win32/kernel32/api/index.htm
In poking around looking for information about this, I came across a Reddit thread where a couple of posters claimed to have found a workaround. Whether those will work for you or are safe to use is another story. Proceed at your own risk. https://www.reddit.com/r/uplay/comments/13uumnq/the_procedure_entry_point_discord_virtual_memory/