(As I understand it) moderator flags are handled at a considerable rate. As such you need to be crystal clear on what you want to say or you will risk a declined flag. At a minimum a moderator flag should include;
- What you want the moderator to do
- Why you want them to do it
- (in some cases) why you can't do it yourself
Your flag didn't have any of these and so didn't get your message across in the couple of seconds a moderator looked at your flag.
Accidently flagging as off topic --> one of the reasons
is a reason for declining a flag because a moderator doesn't need to deal with those. Now your flag isn't one of these, but it really looks like one.
Should this be closed
Perhaps, it is outside my area of expertise and so I can't gauge if this is requesting code so as to be at risk of the "minimum understanding". Its certainly within the region of generally on topic questions
Was the moderator right to decline the flag
Yes, because moderator time is precious and the flag was not crystal clear. Completely separately from if the post should be closed