It is possible, but can't be done with just vanilla SRB2('s Lua). It will need an external software to bridge Discord and SRB2.
For example, it can be done by first creating a little program that reads Discord chat and outputs the messages into a file, then using SRB2 to constantly read this file, pass these lines to SRB2 somehow (like having the console run a fake "say" command), and probably blank the file.
Then the same but for the other way around.
You might run into an issue where both programs try to access a file at the same time, but that's mostly unavoidable.
If you know how to work the game's source code, you could import a network library of sorts to help you out instead of playing who has priority with the files.