Which SR version are you on? Firing a custom event from a listener is already a built in feature.
Go the Script Listeners page and click "Fire an event when condition is true."
You can configure when you want to fire the event and which event to fire.
If you need to create a new custom event, you should see this page in the Atlassian docs:
Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events