DeleteCursorItem() never working

I’m trying to make an addon that manages soul shards, but I’m having problems with using DeleteCursorItem() because its not registering my slash command as a hardware event. How do I properly manage this?

SOUL_SHARDS_TO_KEEP = 5
SOUL_SHARD_ITEMID = 6265

function GetCurrentSoulShards()
    count = 0
    for bagIndex = 0, 4 do
        bagSlots = C_Container.GetContainerNumSlots(bagIndex)
        for bagSlot = 0, bagSlots do
            if C_Container.GetContainerItemID(bagIndex, bagSlot) == SOUL_SHARD_ITEMID then
                count = count + 1
            end
        end
    end
    return count
end

function ManageSoulShards()
    if CursorHasSoulShard() then
        DeleteCursorItem()
    end

    currentSoulShards = GetCurrentSoulShards()
    if currentSoulShards > SOUL_SHARDS_TO_KEEP then
        PickupItem(SOUL_SHARD_ITEMID)
        if CursorHasSoulShard() then
            print("Deleting soulshard...")
            DeleteCursorItem()
        end
    end
end

function CursorHasSoulShard()
    cursorInfoType, itemId = GetCursorInfo()
    if tonumber(itemId) == SOUL_SHARD_ITEMID then
        return true
    end
    return false
end

SLASH_MANAGESOULSHARDS1 = "/mss" 
SlashCmdList["MANAGESOULSHARDS"] = function() 
    ManageSoulShards()
end 

EDIT:

This cannot be called directly from /script (RunScript) and loadstring, e.g. WowLua and WeakAuras.
* Limited to deleting a single item per hardware event. 
As of 2022-09-17 Classic (Vanilla and Wrath) can delete multiple items per hardware event and has no NOSCRIPT protection.

You can’t use DeleteCursorItem from a macro or slash command.
Run your script (or pick up a shard from your bag) and while the cursor has a shard, try
/run DeleteCursorItem()
You should get a “FORCE TAINT STRONG” error which is the NOSCRIPT part of the wiki entry.

As of 2022-09-17 Classic (Vanilla and Wrath) can delete multiple items per hardware event and has no NOSCRIPT protection. I’m not finding this to be the case.

Did you try the test? It would indicate if maybe the wiki is out-of-date on this.