It looks like a clua exposure for this was already added to mainline (at least, for spells, and maybe also evoked items that have matching spell names) in a 2019 PR by mgdelmonte:
https://github.com/crawl/crawl/commit/3 ... e1f15b986fSo, you *should* already be able to use `m:defeat_wl("spell_name", evoked)` in a similar way to checking for `m:attitude()` or `m:is_firewood()`. [Disclaimer: I haven't tested this, I'm just running grep on the source.]
Please see
l-moninf.cc for details.
However, my brief reading of `moninf_get_defeat_wl` suggests that it might(?) only work with actual spells (and not player abilities?) -- (There's a comparison in `spell_by_name` that checks against NUM_SPELLS, so `moninf_get_defeat_wl` might need some minor changes to work with non-spells? I don't feel like testing this and I'm not going down this rabbit hole right now, good luck~)
tl;dr: If there's something broken with this function in actual use, I'm sure improvements would be welcomed by the devteam as a PR.