import functools


def delete_command_message(delay=10, only_on_success=False):
    """Return command decorator that deletes the command message."""

    def decorator(command):
        @functools.wraps(command)
        async def wrapper(self, ctx, *args, **kwargs):
            ret = await command(self, ctx, *args, **kwargs)
            if not only_on_success or ret:
                await ctx.message.delete(delay=delay)
            return ret

        return wrapper

    return decorator