A 36-year-old carpenter who left a pub following a row before returning with a gun which went off during a struggle has appeared before Dundalk Circuit Court for sentencing.